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

introundBytesUpToWords(int bytes)
round Bytes Up To Words
return (bytes + 7) / 8;
longroundChipRewardDown(long chips)
round Chip Reward Down
if (chips < 1000)
    return chips;
int digits = ((int) Math.floor(Math.log(chips) / LOG_10)) + 1;
double divider = Math.pow(10, (digits - 1));
chips = (long) (Math.floor(chips / divider) * divider);
return chips;
StringroundCss(double v, int n)
round Css
return String.valueOf(Math.round(v * e[n]) / e[n]);
doublerounded(double value, int places, int ceilOrFloor)
Method responsible for rounded numerical values (double)
double arredondado = value;
arredondado *= (Math.pow(10, places));
if (ceilOrFloor == 0) {
    arredondado = Math.ceil(arredondado);
} else {
    arredondado = Math.floor(arredondado);
arredondado /= (Math.pow(10, places));
...
longROUNDED_DIV(long a, long b)
ROUNDEDIV
return ((a > 0 ? a + (b >> 1) : a - (b >> 1)) / b);
longrounded_shift_down(long x, int n)
roundeshifdown
if (n == 0)
    return (x);
else {
    return ((x >> (n - 1)) >> 1);
doubleroundedApply(double value, double percent, double delta)
Applies the value with percent and rounds the result if its in space of the delta.
double correct = Math.round(value * (1 + percent) * 100.0) / 100.0;
double rounded = Math.round(correct);
if (Math.abs(rounded - correct) < delta)
    return rounded;
return correct;
StringroundedDollarValue(double d)
rounded Dollar Value
return numberValue(Math.round(d));
doubleroundedLog(double value, double exponent)
a rounded logarithm to avoid issues with jvm dependant math functions
return Math.round(log(value, exponent) * ROUNDED_LOG_PRECISION) / ROUNDED_LOG_PRECISION;
introundedLog10(int n)
rounded Log
int j = 0;
int p = 1;
while (p < n) {
    p *= 10;
    j++;
return j;