>>227
public static double round2(double val, int digit){
double weight = digit > 0 ? Math.pow(10, digit) : 1/Math.pow(10, -digit);
return Math.round(val / weight) * weight;
}