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

introundToDimensions(int value, int nearestValue)
Round.
return Math.round(value / nearestValue) * nearestValue;
longroundToEight(long i)
Memory size of objects are rounded to multiple of 8 bytes
return 8 * ((i + 7) / 8); 
floatroundToHalf(float x)
Round to half float.
return (float) (Math.ceil(x * 2) / 2);
introundToInt(double d)
Round.
return (int) Math.round(d);
introundToInt(double d)
round To Int
return (int) Math.round(d);
introundToInt(final double d)
Rounds d to an int.
return (int) (d + 0.5);
floatroundToInterval(float num, float interval)
round To Interval
if (interval == 0f)
    return num;
return (float) ((double) Math.round(num / interval) * interval);
doubleroundToMil(double val)
round To Mil
double r = val * 1000.0;
int l = (int) r;
if (r - l >= 0.5)
    l++;
r = (double) l / 1000.0;
return r;
introundToMultiple(int value, int divisor)
round To Multiple
int rem = value % divisor;
if (rem == 0)
    return (value);
return (value + divisor - rem);
introundToMultiple(int value, int multipleOf)
Rounds a value to the nearest number that is a specific multiple.
return (int) Math.round((double) value / multipleOf) * multipleOf;