public class Round
extends java.lang.Object
With respect to the rounding up and down operations, if the operand is within machine precision (as defined by the global variable TOLERANCE) of one of the desired ``roundable'' values, then it will be left at that value and not rounded up or down. This is to ensure more predicatable behavior.
Modifier and Type  Field and Description 

static double 
TOLERANCE 
Constructor and Description 

Round() 
Modifier and Type  Method and Description 

static double 
down125(double x)
Rounds a number x down to the nearest value defined by

static double 
down125(int[] factors,
double x)
Rounds a number x down to the nearest value defined by

static double 
downPow2(double x)
Rounds a number x down to the nearest value defined by

static double 
near125(double x)
Rounds a number x to the nearest value defined by

static double 
near125(int[] factors,
double x)
Rounds a number x to the nearest value defined by

static double 
nearPow2(double x)
Rounds a number x to the nearest value defined by

static double 
up125(double x)
Rounds a number x up to the nearest value defined by

static double 
up125(int[] factors,
double x)
Rounds a number x up to the nearest value defined by

static double 
upPow2(double x)
Rounds a number x up to the nearest value defined by

public static final double TOLERANCE
public static double down125(double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
x
 number to round downpublic static double down125(int[] factors, double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
factors
 if not null
, returns the values of
k
and n
described above, in
factors[0]
and factors[1]
, respectively.x
 number to round downpublic static double up125(double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
x
 number to round uppublic static double up125(int[] factors, double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
factors
 if not null
, returns the values of
k
and n
described above, in
factors[0]
and factors[1]
, respectively.x
 number to round uppublic static double near125(double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned.
x
 number to roundpublic static double near125(int[] factors, double x)
sgn(x) k 10^nwhere n is an integer and k is 1, 2, or 5. If x is zero, then zero is returned.
factors
 if not null
, returns the values of
k
and n
described above, in
factors[0]
and factors[1]
, respectively.x
 number to roundpublic static double downPow2(double x)
sgn(x) 2^nwhere n is an integer. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
x
 number to round downpublic static double upPow2(double x)
sgn(x) 2^nwhere n is an integer. If x is zero, then zero is returned. See the note about rounding tolerance in the class documentation.
x
 number to round uppublic static double nearPow2(double x)
sgn(x) 2^nwhere n is an integer. If x is zero, then zero is returned.
x
 number to round