Java Utililty Methods Double Number Round

List of utility methods to do Double Number Round

Description

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

Method

intround_double(double d)
roundouble
return (int) Math.round(d);
Doubleround_nearestmultipleof5(double value)
rounnearestmultipleof
if (value % 5 == 0) {
    return value;
} else if (value % 5 < 2.5) {
    return value - value % 5;
} else {
    return value + (5 - value % 5);
doubleroundAndScale(double startValue, int places)
round And Scale
double multiplier = calculateMultiplier(places);
double ourNoughtPointFive = 0.50000000001;
double absoluteValue = Math.abs(startValue);
double valueToBeFloored = (absoluteValue * multiplier) + ourNoughtPointFive;
double roundedValue = Math.floor(valueToBeFloored);
double returnValue = roundedValue / multiplier;
if (startValue < 0)
    returnValue = -returnValue;
...
doubleroundAngle(double a, long n)
round Angle
return Math.round(a * n) / n;
doubleroundAtDecimals(double number, int deci)
round At Decimals
int decimal = deci * 10;
number = number * decimal;
Math.round(number);
return number / decimal;
introundAway(double d)
round Away
return (int) (d < 0 ? Math.floor(d) : Math.ceil(d));
doubleroundAwayFromZero(double num)
round Away From Zero
if (num >= 0.0)
    return (Math.round(num + 0.49999999999999)); 
else
    return (Math.round(num - 0.49999999999999)); 
doubleroundBig(double d)
round Big
long i = (long) d;
d -= i;
return i + (d >= 0.5 ? 1 : (d <= -0.5 ? -1 : 0));
floatroundDec(float num, int dec)
round Dec
return (float) Math.round(num * (10 ^ dec)) / (10 ^ dec);
DoubleroundDecimal(Double value)
round Decimal
return roundDecimal(value, DEFAULT_DECIMALS);