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

voidRound(Object in)
Round
if (in == null)
    return;
if (in instanceof int[]) {
    int[] inn = (int[]) in;
    for (int i = 0, s = inn.length; i < s; i++)
        inn[i] = (int) (int) inn[i];
} else {
    for (int i = 0, s = ((Object[]) in).length; i < s; i++)
...
Stringround(String num, int length)
round
if (num.indexOf('.') < 0)
    return num;
if (num.length() <= length)
    return num;
if (num.charAt(length) >= '5' && num.charAt(length) != '.') {
    char[] temp = new char[length + 1];
    int ct = length;
    boolean rounding = true;
...
intround4(int n)
round
return n + round4[n & 3];
intround_pow2(int x)
Round_pow2.
int ans = 1;
while (ans < x) {
    ans *= 2;
return ans;
intround_up(int value, int multiple)
Round a number up to a given multiple.
return (((value - 1) / multiple) + 1) * multiple;
introundAdd(double a, double b)
Addieren und dann das Ergebnis runden.
return round(a + b);
introundAndCrop(final float x, final int min, final int max)
First calls Math.round with x and then crops the resulting value to the range min to max.
final int rx = Math.round(x);
return crop(rx, min, max);
introundByGridSize(int value)
round By Grid Size
value = value + (GRID_SIZE / 2);
value = value / GRID_SIZE;
value = value * GRID_SIZE;
return value;
introundByte(final double value)
Rounds a float value and clamp the result between 0 and 255 inclusive.
return (int) Math.min(Math.max(Math.round(value), 0), 255);
introundBytesToGB(long bytes)
Round bytes to GiB (gibibyte)
return Math.round((float) bytes / 1024 / 1024 / 1024);