Documentation of 'com.jstatcom.util.UMath' Java class
UMath
com.jstatcom.util

Class UMath



  • public final class UMath
    extends java.lang.Object
    This class is a collection of some mathematical functions. It can be used in addition to the Math class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static double[] base10(double arg)
      Transforms arbitrary double values to a double in the interval (-10,-1] or [1,10) and a power of 10.
      static int closestMultiple(int value, int unit)
      Computes the closest multiple of unit for value.
      static double round(double arg, int n)
      Rounds the arg to a number with n decimal digits, for example 2.368=round(2.367849,3) If arg is NaN or +/-INF, then arg is returned.
      static int sign(int arg)
      Returns -1 if arg is smaller than zero and 1 if it is greater or equal to zero.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • base10

        public static double[] base10(double arg)
        Transforms arbitrary double values to a double in 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. If arg is NaN or +/-INF, then {arg, 0} is returned.
        Parameters:
        arg - the number to break
        Returns:
        two dimensional double array
        • double[0] the mantisse
        • double[1] the power of 10
      • closestMultiple

        public static int closestMultiple(int value,
                                          int unit)
        Computes the closest multiple of unit for value. If value is just in the middle between two multiples of unit, the higher multiple is choosen, for example 15 == closestMultiple(13, 5), 10 == closestMultiple(12, 5), 8 == closestMultiple(7, 4).
        Parameters:
        value - defines a closest multiple of unit
        unit - defines the steps
        Returns:
        closest multiple of unit for value, returns value if (unit == 1), returns 0 if (unit == 0)
      • round

        public static double round(double arg,
                                   int n)
        Rounds the arg to a number with n decimal digits, for example 2.368=round(2.367849,3) If arg is NaN or +/-INF, then arg is returned.
        Parameters:
        arg - the number to round
        n - the number of decimal digits to round for
        Returns:
        the rounded number
      • sign

        public static int sign(int arg)
        Returns -1 if arg is 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

You see the box below because you did not login.