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

doubleroundOff(double fraction, int precision)
Rounds off fraction to the given amount of precision.
int i = 0;
int finalNum = 1;
while (i++ < precision) {
    finalNum *= 10;
return (double) Math.round(fraction * finalNum) / finalNum;
doubleroundOffAmt(double dAmt)
round Off Amt
return Math.round(dAmt * 10000000000.0) / 10000000000.0;
StringroundOffFileCount(int fileCount)
round Off File Count
String fileCountStr = String.valueOf(fileCount);
if (fileCountStr.length() == 1) {
    fileCountStr = "0" + fileCountStr;
return fileCountStr;
doubleroundOffTo2DecPlaces(double val)
round Off To Dec Places
return Math.round(val * 100) / 100;
double[]roundOffValues(double[] doubles)
round Off Values
double[] returnDoubles = new double[doubles.length];
for (int i = 0; i < doubles.length; i++) {
    returnDoubles[i] = Math.round(doubles[i]);
return returnDoubles;
doubleroundPhred(final double value, final double phredScorePrecision)
Round a Phred scaled score to precision phredScorePrecision
return Math.round(value / phredScorePrecision) * phredScorePrecision;
introundPos(final float a)
Round a positive a
return (int) (a + 0.5f);
introundPositive(float value)
Returns the closest integer to the specified float.
return (int) (value + 0.5f);
introundPositive(float x)
round Positive
return (int) (x + 0.5f);
introundPositiveIntToPowerOf2(int i)
round Positive Int To Power Of
if (i <= 0) {
    throw new IllegalArgumentException();
return Integer.bitCount(i) == 1 ? i : Integer.highestOneBit(i) << 1;