List of utility methods to do Number Round
float | roundTimeValue(final float defaultUnitValue, final boolean is24HourFormatting) round Time Value float unit = defaultUnitValue; int multiplier = 1; if (is24HourFormatting) { while (unit > 120) { multiplier *= 60; unit /= 60; if (multiplier >= 3600) { ... |
Double | roundTo(double aValue, int aDigits) Rounds a double value to digit digits after the point.
double d = Math.pow(10, aDigits); return new Double(Math.round(aValue * d) / d); |
double | roundTo(double d, int n) returns the rounded result of the argument to the n digits after the decimal point. d *= Math.pow(10, n);
d = Math.round(d);
d /= Math.pow(10, n);
return d;
|
double | roundTo(double num, int dp) round To int dpM = (int) Math.pow(10, dp); return Math.round(num * dpM) / dpM; |
double | roundTo(double val, double prec) Rounds a double precision value to the given precision. return floor(val / prec + 0.5) * prec; |
double | roundTo(final double VALUE, final double TARGET) round To return TARGET * (Math.round(VALUE / TARGET));
|
float | roundTo(float number, int base) round To return Math.round(number * 10 * base) / (10f * base);
|
float | roundTo(float number, int numPlaces) (Based on round() in PHP) if (numPlaces <= 1) return Math.round(number); float exponent = (float) Math.pow(10, numPlaces); return Math.round(number * exponent) / exponent; |
float | roundTo(float val, int numPlaces) Returns the rounded value of val to specified number of digits after the decimal point. (Based on round() in PHP) if (numPlaces <= 1) return Math.round(val); float exponent = (float) Math.pow(10, numPlaces); return (Math.round(val * exponent) / exponent); |
double | roundTo100th(double w) round Toth return Math.floor(w * 100 + 0.5) / 100;
|