List of utility methods to do Number Round
String | roundedSatisfaction(double value) rounded Satisfaction return String.format("%1$#.2f", value); |
float | rounder(float value, int digits) rounder return Math.round(value * Math.pow(10, digits) + 0.5) / (float) Math.pow(10, digits); |
float | roundf(float value) roundf float rest = value % 1f; if (rest >= 0.5f) { value += 1f - rest; } else { value -= rest; return value; |
long | roundFileLength(long nbytes) round File Length if (nbytes <= 0) return 0; else if (nbytes <= 512) return nbytes; else if (nbytes % 512 == 0) return nbytes; else return (int) (nbytes / 512 + 1) * 512; ... |
float | roundFloat(float value, int afterDecimalPoint) Rounds a double to the given number of decimal places. float mask = (float) Math.pow(10, (float) afterDecimalPoint); return (float) (Math.round(value * mask)) / mask; |
float | roundFloatToPlace(float f, int place) round Float To Place if (place < 0) throw new IllegalArgumentException(); if (place > 9) throw new IllegalArgumentException(); long factor = (long) Math.pow(10, place); return ((float) Math.round(f * factor)) / factor; |
long | roundFloatToUnitInverse(final float graphValue, final float graphUnit) Round floating value to an inverse long value. if (graphUnit < 1) { if (graphValue < 0) { final float value1 = graphValue / graphUnit; final float value2 = value1 - 0.5f; final long value3 = (long) (value2); return value3; } else { final float value1 = graphValue / graphUnit; ... |
String | roundFormat(final int numPrec, final double number) Round format. return String.format("%." + numPrec + "f", number); |
double | RoundFullUp(double d) Adds .5 and rounds the result...this should round up to the full integer anything <.4 return Math.round(.4 + d);
|
double | roundHalfAway(double d) round Half Away if (d < 0) { d = Math.ceil(d - 0.5); } else if (d > 0) { d = Math.floor(d + 0.5); return d; |