Java Utililty Methods Number Round

List of utility methods to do Number Round

Description

The list of methods to do Number Round are organized into topic(s).

Method

StringroundToString(double nb2round, int nbOfDigits)
Round to string.
if (nbOfDigits == 0)
    return "" + Math.round(nb2round);
return new Double(round(nb2round, nbOfDigits)).toString();
introundToTop(float f)
round To Top
if (f > (int) f)
    return (int) (f + 1);
return (int) f;
longroundToWord(long value)
Return the smallest multiple of four (4) that is greater than or equal to the given value.
return value + ROUND_UP_AMOUNT[(int) (value % 4)];
introundToZero(float x)
round To Zero
return (int) x;
doubleroundTwoDecimals(double value)
Rounds the passed value to two decimals after decimal point.
return round(value, 2);
introundUp(double a)
Returns the closest int to the argument, with ties rounding up.
return (int) Math.round(a);
longroundUp(double d)
round Up
return Math.round(d * 10.0) / 10;
introundUP(double d)
round UP
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;
introundUp(double n)
Round the given number to the nearest whole that is greater than the number.
return roundDown(n) + 1;
doubleroundUp(double n, int precision)
Rounds up number with precise
return (double) (Math.round(n * Math.pow(10, precision)) / Math.pow(10, precision));