|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.util.Round
public class Round
Class that supports rounding numbers with respect to k 10^n, where n is an integer and k is 1, 2, or 5, or with respect to 2^n, where n is an integer. These methods are mainly intended for automatic scaling operations.
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.
Field Summary | |
---|---|
static double |
TOLERANCE
|
Constructor Summary | |
---|---|
Round()
|
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double TOLERANCE
Constructor Detail |
---|
public Round()
Method Detail |
---|
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 down
public 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 down
public 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 up
public 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 up
public 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 round
public 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 round
public 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 down
public 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 up
public 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |