List of utility methods to do Number Round
double | roundTo2Decimals(double value) round To Decimals return (double) Math.round(value * 100) / 100; |
double | roundTo2Digits(double amount) round To Digits long number2 = Math.round(amount * 100); return (double) (number2 / 100); |
double | roundTo2SigPlaces(double value) Round double to 2- significant places return Math.round(value * 100.0) / 100.0f;
|
double | roundTo3Places(double n) round To Places return Math.round(n * 1000d) * 0.001;
|
Double | roundTo6decimals(Double x) round Todecimals return x == null ? null : Math.round(x * Math.pow(10, 6)) / Math.pow(10, 6);
|
float | roundToAccuracy(float n, float i) round To Accuracy int cutoffN = (int) (n / i); return cutoffN * i; |
int | roundToBase(int a, int base) Returns the nearest number to a multiple of a given number. return a - a % base;
|
int | roundToBytes(int bitWidth) Returns the number of bytes necessary to contain the given bit-width. return (int) Math.ceil((double) bitWidth / 8); |
long | roundToDay(long time) Rounds the time to an exact day. return time / (24 * 60 * 60) * (24 * 60 * 60);
|
double | roundToDecentPrecision(double value) round To Decent Precision double z = Math.round(roundValue * value); return z / roundValue; |