|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--texsoft.java.util.XsMath
This abstract class provides some math static methods, moslty for rounding purposes.
Constructor Summary | |
XsMath()
|
Method Summary | |
static double |
log10(double x)
Returns the log10 of x. |
static void |
main(java.lang.String[] args)
Simple test code. |
static double |
pow10(int pow)
Return 10pow. |
static double |
round(double value,
int log)
Round value to log decimal weight. |
static double |
roundDown(double value,
int log)
Round DOWN value to log decimal weight. |
static double |
roundUp(double value,
int log)
Round UP value to log decimal weight. |
static double |
trunc(double value,
int log)
Truncate value to log decimal weight. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XsMath()
Method Detail |
public static double trunc(double value, int log)
Use negative log value for decimal. Examples:
trunc(123.456, -4) = 123.456 trunc(123.456, -3) = 123.456 trunc(123.456, -2) = 123.45 trunc(123.456, -1) = 123.4 trunc(123.456, 0) = 123.0 trunc(123.456, 1) = 120.0 trunc(123.456, 2) = 100.0 trunc(123.456, 3) = 0.0
value
- value to be truncated.log
- truncate value to the this decimal weight.
Negative values mean decimal positions.
public static double round(double value, int log)
Use negative log value for decimals. Examples:
round(123.446, -4)=123.446 round(123.446, -3)=123.446 round(123.446, -2)=123.45 round(123.446, -1)=123.4 round(123.446, 0)=123.0 round(123.446, 1)=120.0 round(153.446, 2)=200.0 round(123.446, 3)=0.0
value
- value to be rounded.log
- round value to the this decimal weight.
Negative values mean decimal positions.
public static double roundUp(double value, int log)
Use negative log value for decimals. Examples:
roundUp(123.456, -4) = 123.456 roundUp(123.456, -3) = 123.456 roundUp(123.456, -2) = 123.46 roundUp(123.456, -1) = 123.5 roundUp(123.456, 0) = 124.0 roundUp(123.456, 1) = 130.0 roundUp(123.456, 2) = 200.0 roundUp(123.456, 3) = 1000.0
value
- value to be rounded up.log
- round up value to the this decimal weight.
Negative values mean decimal positions.
public static double roundDown(double value, int log)
Use negative log value for decimals. Examples:
roundDown(123.456, -4)=123.456 roundDown(123.456, -3)=123.456 roundDown(123.456, -2)=123.45 roundDown(123.456, -1)=123.4 roundDown(123.456, 0)=123.0 roundDown(123.456, 1)=120.0 roundDown(123.456, 2)=100.0 roundDown(123.456, 3)=0.0
value
- value to be rounded down.log
- round down value to the this decimal weight.
Negative values mean decimal positions.
public static double pow10(int pow)
pow
- exponent.
public static double log10(double x)
x
- value whose log10 has to be calculated.
public static void main(java.lang.String[] args)
args
- command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |