How could I always round up a double to an int, and never round it down. I know of Math.round(double), but I want it to always round u
double
int
Math.round(double)
private int roundUP(double d){ double dAbs = Math.abs(d); int i = (int) dAbs; double result = dAbs - (double) i; if(result==0.0){ return (int) d; }else{ return (int) d<0 ? -(i+1) : i+1; } }
Good job ! ;)