List of utility methods to do Double Number Round
double | round(double value, int scalar, int standard) round return Double.parseDouble(round(String.valueOf(value), scalar, standard));
|
double | round(double valueToRound, int numberOfDecimalPlaces) round if (Double.isNaN(valueToRound)) return Double.NaN; double multipicationFactor = Math.pow(10, numberOfDecimalPlaces); double interestedInZeroDPs = valueToRound * multipicationFactor; return Math.round(interestedInZeroDPs) / multipicationFactor; |
double | round(double valueToTruncate, int requiredDecimalPlaces) round assert requiredDecimalPlaces >= 0 : "Can't round to a negative number of decimal places!"; double scalingFactor = Math.pow(10d, requiredDecimalPlaces); double scaledValueToTruncate = valueToTruncate * scalingFactor; int roundedScaledValueToTruncate = (int) (scaledValueToTruncate + 0.5d); return ((double) roundedScaledValueToTruncate) / scalingFactor; |
double | round(double what, int howmuch) round return (double) ((int) (what * Math.pow(10, howmuch) + .5)) / Math.pow(10, howmuch); |
double | round(double x) round return Math.floor((x + 0.5));
|
int | round(double x) A fast implementation of Math#round(double) . return (int) (x + BIG_ENOUGH_ROUND) - BIG_ENOUGH_INT; |
int | round(double x) Data un valore decimale ritorna un intero che lo arrotondato return (int) Math.round(x); |
double | round(double x) round return round(x, 1);
|
double | round(double x, int numPlaces) round double scale = Math.pow(10, numPlaces); return Math.round(x * scale) / scale; |
double | round(double x, int places) round long m = pow(10, places); return Math.rint(x * m) / m; |