Java Utililty Methods Number Round

List of utility methods to do Number Round

Description

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

Method

doubleroundSignificant(double value)
Rounds a number, keeping at least 3 significant digits.
if (value >= 10.0 || value <= -10.0) {
    return getRounded(value, 1);
} else {
    return roundToSignificantDigits(value, 3);
introundSimpleNumberUnits(final long graphDefaultUnit)
round Simple Number Units
float unit = graphDefaultUnit;
int multiplier = 1;
while (unit > 20) {
    multiplier *= 10;
    unit /= 10;
unit = 
        unit >= 10 ? 10 : 
...
int[]roundSizes(float[] sizes)
Round a number of float sizes into int sizes so that the total length match up
int[] retInts = new int[sizes.length];
float posD = 0;
for (int i = 0; i < retInts.length; i++) {
    int posI = (int) (posD + 0.5f);
    posD += sizes[i];
    retInts[i] = (int) (posD + 0.5f) - posI;
return retInts;
...
doubleroundSonekiSuii(double amount1, double amount2)
round Soneki Suii
return round(((amount1 / amount2) * 100), 1);
introundsToTicks(double x)
D&D rounds to ticks (2 seconds per round)
return secondsToTicks(x * SEC_PER_ROUND);
StringroundStr(Double value, int decimal)
round Str
return String.format("%1." + decimal + "f", value);
StringroundString(double d)
Rounds the number returning a string representation of the numner
if (d == 0.0)
    return "" + d;
int digits = (int) (Math.log(d) / Math.log(10));
int n = 3 - digits;
return fixBug("" + round(d, n), n);
StringroundString(double n, double range, double precision)
round String
double v = range * precision;
int i = 0;
while (v < 1) {
    v *= 10;
    i++;
return roundString(n, i);
longroundTime24h(final long defaultUnitValue)
round Timeh
float unit = defaultUnitValue;
int multiplier = 1;
while (unit > 3600) {
    multiplier *= 3600;
    unit /= 3600;
float unitRounded = unit;
if (multiplier >= 3600) {
...
longroundTimeStamp(long tstamp)
round Time Stamp
return (tstamp / 1000) * 1000;