com.jstatcom.util
Class UMath
- java.lang.Object
-
- com.jstatcom.util.UMath
-
public final class UMath extends java.lang.ObjectThis class is a collection of some mathematical functions. It can be used in addition to theMathclass.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static double[]base10(double arg)Transforms arbitrarydoublevalues to adoublein the interval (-10,-1] or [1,10) and a power of 10.static intclosestMultiple(int value, int unit)Computes the closest multiple ofunitforvalue.static doubleround(double arg, int n)Rounds theargto a number withndecimal digits, for example2.368=round(2.367849,3)Ifargis NaN or +/-INF, thenargis returned.static intsign(int arg)Returns -1 ifargis smaller than zero and 1 if it is greater or equal to zero.
-
-
-
Method Detail
-
base10
public static double[] base10(double arg)
Transforms arbitrarydoublevalues to adoublein the interval (-10,-1] or [1,10) and a power of 10. It breaks number to a number of the form #.####... and a power of 10.{ mant,pow } = base10(arg) with mant * 10^pow == arg returnValue[0]=mant, returnValue[1]=pow. Ifargis NaN or +/-INF, then{arg, 0}is returned.- Parameters:
arg- the number to break- Returns:
- two dimensional
doublearraydouble[0]the mantissedouble[1]the power of 10
-
closestMultiple
public static int closestMultiple(int value, int unit)Computes the closest multiple ofunitforvalue. Ifvalueis just in the middle between two multiples ofunit, the higher multiple is choosen, for example15 == closestMultiple(13, 5), 10 == closestMultiple(12, 5), 8 == closestMultiple(7, 4).- Parameters:
value- defines a closest multiple of unitunit- defines the steps- Returns:
- closest multiple of
unitforvalue, returnsvalue if (unit == 1), returns 0if (unit == 0)
-
round
public static double round(double arg, int n)Rounds theargto a number withndecimal digits, for example2.368=round(2.367849,3)Ifargis NaN or +/-INF, thenargis returned.- Parameters:
arg- the number to roundn- the number of decimal digits to round for- Returns:
- the rounded number
-
sign
public static int sign(int arg)
Returns -1 ifargis smaller than zero and 1 if it is greater or equal to zero.- Parameters:
arg- the number to check the sign for- Returns:
- -1
if (arg < 0), otherwise 1
-
-
DMelt 3.0 © DataMelt by jWork.ORG