Class MathUtil

java.lang.Object
de.uplanet.lucy.server.auxiliaries.MathUtil

@VelocityCallable("singleton") public final class MathUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final long
     
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    abs(double p_dblX)
    Returns the absolute value of a double value.
    float
    abs(float p_fltX)
    Returns the absolute value of a float value.
    int
    abs(int p_iX)
    Returns the absolute value of an int value.
    long
    abs(long p_lX)
    Returns the absolute value of a long value.
    add(Number p_numL, Number p_numR)
    Adds two numbers.
    double
    ceil(double p_dbl)
    Returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer.
    double
    circleX(Number p_numX, Number p_numRadius, Number p_numAngle)
    Calculate the x-coordinate of a point on a ellipse.
    double
    circleX(Number p_numX, Number p_numRadius, Number p_numNum, Number p_numDenom)
    Calculate the x-coordinate of a point on a ellipse.
    int
    circleXInt(Number p_numX, Number p_numRadius, Number p_numAngle)
    Calculate the x-coordinate of a point on a ellipse.
    int
    circleXInt(Number p_numX, Number p_numRadius, Number p_numNum, Number p_numDenom)
    Calculate the x-coordinate of a point on a ellipse.
    double
    circleY(Number p_numY, Number p_numRadius, Number p_numAngle)
    Calculate the y-coordinate of a point on a ellipse.
    double
    circleY(Number p_numY, Number p_numRadius, Number p_numNum, Number p_numDenom)
    Calculate the y-coordinate of a point on a ellipse.
    int
    circleYInt(Number p_numY, Number p_numRadius, Number p_numAngle)
    Calculate the y-coordinate of a point on a ellipse.
    int
    circleYInt(Number p_numY, Number p_numRadius, Number p_numNum, Number p_numDenom)
    Calculate the y-coordinate of a point on a ellipse.
    double
    cos(Number p_num)
    Get the trigonometric cosine of the given angle.
    double
    cosDeg(Number p_num)
    Get the trigonometric cosine of the given angle.
    double
    deg2rad(Number p_num)
    Convert degrees to radians.
    div(Number p_numL, Number p_numR)
    Divides one number by another.
    double
    exp(Number p_numExponent)
    Returns Euler's number e raised to given power as a double.
    double
    floor(double p_dbl)
    Returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer.
    boolean
    ge(Number p_numL, Number p_numR)
    Determine if the first number is greater or equal as the second number.
    double
    Get the value of π, i.e.
    int
    getRandomInt(int p_iMinValue, int p_iMaxValue)
     
    long
    getRandomLong(long p_lMinValue, long p_lMaxValue)
     
    boolean
    gt(Number p_numL, Number p_numR)
    Determine if the first number is greater than the second number.
    int
    idiv(Number p_numL, Number p_numR)
    Divides the int part of first number by the int part of the second.
    int
    imod(Number p_numL, Number p_numR)
    Calculates the int part of first number modulo the int part of the second.
    boolean
    isInfinite(double p_dbl)
    Check if the specified number is infinitely large in magnitude.
    boolean
    isInfinite(float p_flt)
    Check if the specified number is infinitely large in magnitude.
    boolean
    isNaN(double p_dbl)
    Check if the specified number is a Not-a-Number (NaN) value.
    boolean
    isNaN(float p_flt)
    Check if the specified number is a Not-a-Number (NaN) value.
    long
    ldiv(Number p_numL, Number p_numR)
    Divides the long part of first number by the long part of the second.
    boolean
    le(Number p_numL, Number p_numR)
    Determine if the first number is less or equal the second number.
    long
    lmod(Number p_numL, Number p_numR)
    Calculates the long part of first number modulo the long part of the second.
    double
    log(Number p_num)
    Returns the natural logarithm (base e) of the given number as a double.
    double
    log10(Number p_num)
    Returns the logarithm to base 10 of the given number as a double.
    boolean
    lt(Number p_numL, Number p_numR)
    Determine if the first number is less than the second number.
    max(Number p_num1, Number p_num2)
    Determine the maximum of the given numbers.
    min(Number p_num1, Number p_num2)
    Determine the minimum of the given numbers.
    mult(Number p_numL, Number p_numR)
    Multiplies two numbers.
    double
    pow(Number p_numBase, Number p_numExponent)
    Returns the value of the first argument raised to the power of the second argument as a double.
    double
    rad2deg(Number p_num)
    Convert radians to degrees.
    double
    ratio2rad(Number p_numNum, Number p_numDenom)
    Convert a ratio to radians.
    double
    roundHalfAwayFromZero(double p_dbl)
    Returns the closest integer to the argument.
    double
    roundHalfAwayFromZero(double p_dbl, int p_iPrecision)
    Returns the closest scaled integer to the argument.
    Returns the closest integer to the argument.
    roundHalfAwayFromZero(BigDecimal p_bd, int p_iPrecision)
    Returns the closest scaled integer to the argument.
    int
    Returns the closest int to the argument.
    long
    Returns the closest long to the argument.
    double
    roundHalfEven(double p_dbl)
    Returns the closest integer to the argument.
    double
    roundHalfEven(double p_dbl, int p_iPrecision)
    Returns the closest integer to the argument.
    Returns the closest integer to the argument.
    roundHalfEven(BigDecimal p_bd, int p_iPrecision)
    Returns the closest scaled integer to the argument.
    int
    roundHalfEvenAsInt(double p_dbl)
    Returns the closest integer to the argument.
    long
    roundHalfEvenAsLong(double p_dbl)
    Returns the closest integer to the argument.
    double
    roundHalfUp(double p_dbl)
    Returns the closest integer to the argument.
    int
    roundHalfUpAsInt(double p_dbl)
    Returns the closest int to the argument.
    long
    roundHalfUpAsLong(double p_dbl)
    Returns the closest long to the argument.
    int
    signum(Number p_num)
    Returns the signum function of the argument.
    double
    sin(Number p_num)
    Get the trigonometric sine of the given angle.
    double
    sinDeg(Number p_num)
    Get the trigonometric sine of the given angle.
    sub(Number p_numL, Number p_numR)
    Subtract two numbers.
    double
    tan(Number p_num)
    Get the trigonometric tangent of the given angle.
    double
    tanDeg(Number p_num)
    Get the trigonometric tangent of the given angle.
    Cast the given value to big decimal.
    toBigDecimal(Object p_value, BigDecimal p_lngFallback)
    Cast the given value to big decimal.
    toDouble(Object p_value)
    Cast the given value to double.
    toDouble(Object p_value, Double p_dblFallback)
    Cast the given value to double.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    toDoubleVH(Object p_value)
    Cast the given value to double and wrap it into a value holder.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    toDoubleVH(Object p_value, Double p_dblFallback)
    Cast the given value to double and wrap it into a value holder.
    toFloat(Object p_value)
    Cast the given value to float.
    toFloat(Object p_value, Float p_fltFallback)
    Cast the given value to float.
    int
    toInteger(Object p_value)
    Cast the given value to integer.
    toInteger(Object p_value, Integer p_intFallback)
    Cast the given value to integer.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    Cast the given value to integer and wrap it into a value holder.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    toIntegerVH(Object p_value, Integer p_intFallback)
    Cast the given value to integer and wrap it into a value holder.
    long
    toLong(Object p_value)
    Cast the given value to long.
    toLong(Object p_value, Long p_lngFallback)
    Cast the given value to long.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    toLongVH(Object p_value)
    Cast the given value to long and wrap it into a value holder.
    de.uplanet.lucy.server.dataobjects.IValueHolder<?>
    toLongVH(Object p_value, Long p_lngFallback)
    Cast the given value to long and wrap it into a value holder.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MathUtil

      public MathUtil()
  • Method Details

    • toInteger

      public int toInteger(Object p_value)
      Cast the given value to integer.

      Valid input types are java.lang.Number, java.lang.Boolean, value holders, or strings (that must not contain decimal grouping symbols).

      Parameters:
      p_value - The value to be cast.
      Returns:
      The integer value.
      Throws:
      ArithmeticException - In case of a range overflow.
      NumberFormatException - If a given string cannot be parsed as an integer.
    • toIntegerVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toIntegerVH(Object p_value)
      Cast the given value to integer and wrap it into a value holder.
      See Also:
    • toInteger

      public Integer toInteger(Object p_value, Integer p_intFallback)
      Cast the given value to integer.
      Parameters:
      p_value - The integer value.
      p_intFallback - The fallback value if p_value is null.
      Returns:
      The integer value.
      See Also:
    • toIntegerVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toIntegerVH(Object p_value, Integer p_intFallback)
      Cast the given value to integer and wrap it into a value holder.
      See Also:
    • toLong

      public long toLong(Object p_value)
      Cast the given value to long.

      Valid input types are java.lang.Number, java.lang.Boolean, value holders, or strings (that must not contain decimal grouping symbols).

      Parameters:
      p_value - The value to be cast.
      Returns:
      The long value.
      Throws:
      ArithmeticException - In case of a range overflow.
      NumberFormatException - If a given string cannot be parsed as a long.
    • toLongVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toLongVH(Object p_value)
      Cast the given value to long and wrap it into a value holder.
      See Also:
    • toLong

      public Long toLong(Object p_value, Long p_lngFallback)
      Cast the given value to long.
      Parameters:
      p_value - The long value.
      p_lngFallback - The fallback value if p_value is null.
      Returns:
      The long value.
      See Also:
    • toLongVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toLongVH(Object p_value, Long p_lngFallback)
      Cast the given value to long and wrap it into a value holder.
      See Also:
    • toFloat

      public Float toFloat(Object p_value)
      Cast the given value to float.

      Note: Prefer double over float where possible.

      Valid input types are java.lang.Number, java.lang.Boolean, value holders, or strings (see Float.valueOf(String)).

      Parameters:
      p_value - The value to be cast.
      Returns:
      The float value.
      Throws:
      ArithmeticException - In case of a range overflow.
      NumberFormatException - If a given string cannot be parsed as a float.
    • toFloat

      public Float toFloat(Object p_value, Float p_fltFallback)
      Cast the given value to float.

      Note: Prefer double over float where possible.

      Parameters:
      p_value - The float value.
      p_fltFallback - The fallback value if p_value is null.
      Returns:
      The float value.
      See Also:
    • toDoubleVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toDoubleVH(Object p_value)
      Cast the given value to double and wrap it into a value holder.
      See Also:
    • toDouble

      public Double toDouble(Object p_value)
      Cast the given value to double.

      Valid input types are java.lang.Number, java.lang.Boolean, value holders, or strings (see Double.valueOf(String)).

      Parameters:
      p_value - The value to be cast.
      Returns:
      The double value.
      Throws:
      ArithmeticException - In case of a range overflow.
      NumberFormatException - If a given string cannot be parsed as a double.
    • toDouble

      public Double toDouble(Object p_value, Double p_dblFallback)
      Cast the given value to double.
      Parameters:
      p_value - The double value.
      p_dblFallback - The fallback value if p_value is null.
      Returns:
      The double value.
      See Also:
    • toDoubleVH

      public de.uplanet.lucy.server.dataobjects.IValueHolder<?> toDoubleVH(Object p_value, Double p_dblFallback)
      Cast the given value to double and wrap it into a value holder.
      See Also:
    • toBigDecimal

      public BigDecimal toBigDecimal(Object p_value)
      Cast the given value to big decimal.

      Valid input types are java.lang.Number, java.lang.Boolean, value holders, or strings.

      Parameters:
      p_value - The value to be cast.
      Returns:
      The big decimal value.
      Throws:
      ArithmeticException - In case of a range overflow.
      NumberFormatException - If a given string cannot be parsed as a big decimal.
    • toBigDecimal

      public BigDecimal toBigDecimal(Object p_value, BigDecimal p_lngFallback)
      Cast the given value to big decimal.
      Parameters:
      p_value - The big decimal value.
      p_lngFallback - The fallback value if p_value is null.
      Returns:
      The big decimal value.
      See Also:
    • abs

      public int abs(int p_iX)
      Returns the absolute value of an int value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.
      Parameters:
      p_iX - The argument whose absolute value is to be determined.
      Returns:
      The absolute value.
    • abs

      public long abs(long p_lX)
      Returns the absolute value of a long value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.
      Parameters:
      p_lX - The argument whose absolute value is to be determined.
      Returns:
      The absolute value.
    • abs

      public float abs(float p_fltX)
      Returns the absolute value of a float value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.
      Parameters:
      p_fltX - The argument whose absolute value is to be determined.
      Returns:
      The absolute value.
    • abs

      public double abs(double p_dblX)
      Returns the absolute value of a double value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.
      Parameters:
      p_dblX - The argument whose absolute value is to be determined.
      Returns:
      The absolute value.
    • signum

      public int signum(Number p_num)
      Returns the signum function of the argument.
      Parameters:
      p_num - The argument.
      Returns:
      Zero if the argument is zero, 1 if the argument is greater than zero, -1 if the argument is less than zero.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • ceil

      public double ceil(double p_dbl)
      Returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer. Special cases:
      • If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
      • If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
      • If the argument value is less than zero but greater than -1.0, then the result is negative zero.
      Parameters:
      p_dbl - The value.
      Returns:
      The smallest (closest to negative infinity) floating-point value that is greater than or equal to the argument and is equal to a mathematical integer. .
    • floor

      public double floor(double p_dbl)
      Returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer. Special cases:
      • If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
      • If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
      Parameters:
      p_dbl - The value.
      Returns:
      The largest (closest to positive infinity) floating-point value that less than or equal to the argument and is equal to a mathematical integer.
    • roundHalfUp

      public double roundHalfUp(double p_dbl)
      Returns the closest integer to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result. In other words, the result is equal to the value of the expression:
       floor(p_dblX + 0.5d)
       
      Examples:
       roundHalfUp(0)    ->  0.0
       roundHalfUp(0.5)  ->  1.0
       roundHalfUp(-0.5) ->  0.0
       roundHalfUp(1)    ->  1.0
       roundHalfUp(-1)   -> -1.0
       
      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • roundHalfUpAsLong

      public long roundHalfUpAsLong(double p_dbl)
      Returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long. In other words, the result is equal to the value of the expression:
       (long)floor(p_dblX + 0.5d)
       
      Examples:
       roundHalfUp(0)    ->  0
       roundHalfUp(0.5)  ->  1
       roundHalfUp(-0.5) ->  0
       roundHalfUp(1)    ->  1
       roundHalfUp(-1)   -> -1
       
      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or less than Long.MIN_VALUE, or greater then Long.MAX_VALUE.
    • roundHalfUpAsInt

      public int roundHalfUpAsInt(double p_dbl)
      Returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression:
       (long)floor(p_dblX + 0.5d)
       
      Examples:
       roundHalfUp(0)    ->  0
       roundHalfUp(0.5)  ->  1
       roundHalfUp(-0.5) ->  0
       roundHalfUp(1)    ->  1
       roundHalfUp(-1)   -> -1
       
      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite, or less than Integer.MIN_VALUE, or greater then Integer.MAX_VALUE.
    • roundHalfAwayFromZero

      public double roundHalfAwayFromZero(double p_dbl)
      Returns the closest integer to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0)    ->  0.0
       roundHalfAwayFromZero(0.5)  ->  1.0
       roundHalfAwayFromZero(-0.5) -> -1.0
       roundHalfAwayFromZero(1)    ->  1.0
       roundHalfAwayFromZero(-1)   -> -1.0
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • roundHalfAwayFromZeroAsLong

      public long roundHalfAwayFromZeroAsLong(double p_dbl)
      Returns the closest long to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0)    ->  0
       roundHalfAwayFromZero(0.5)  ->  1
       roundHalfAwayFromZero(-0.5) -> -1
       roundHalfAwayFromZero(1)    ->  1
       roundHalfAwayFromZero(-1)   -> -1
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite, or less than Long.MIN_VALUE, or greater then Long.MAX_VALUE.
    • roundHalfAwayFromZeroAsInt

      public int roundHalfAwayFromZeroAsInt(double p_dbl)
      Returns the closest int to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0)    ->  0
       roundHalfAwayFromZero(0.5)  ->  1
       roundHalfAwayFromZero(-0.5) -> -1
       roundHalfAwayFromZero(1)    ->  1
       roundHalfAwayFromZero(-1)   -> -1
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite, or less than Integer.MIN_VALUE, or greater then Integer.MAX_VALUE.
    • roundHalfAwayFromZero

      public double roundHalfAwayFromZero(double p_dbl, int p_iPrecision)
      Returns the closest scaled integer to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0.0, 2)     ->    0.0
       roundHalfAwayFromZero(1.0, 2)     ->    1.0
       roundHalfAwayFromZero(-1.0, 2)    ->   -1.0
       roundHalfAwayFromZero(1.255, 2)   ->    1.26
       roundHalfAwayFromZero(-1.255, 2)  ->   -1.26
       roundHalfAwayFromZero(123.5, -2)  ->  100.0
       roundHalfAwayFromZero(-123.5, -2) -> -100.0
       

      Parameters:
      p_dbl - The value to be rounded.
      p_iPrecision - The precision (may be a negative value).
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • roundHalfAwayFromZero

      public BigDecimal roundHalfAwayFromZero(BigDecimal p_bd)
      Returns the closest integer to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0)    ->  0.0
       roundHalfAwayFromZero(0.5)  ->  1.0
       roundHalfAwayFromZero(-0.5) -> -1.0
       roundHalfAwayFromZero(1)    ->  1.0
       roundHalfAwayFromZero(-1)   -> -1.0
       

      Parameters:
      p_bd - The value to be rounded.
      Returns:
      The rounded value.
    • roundHalfAwayFromZero

      public BigDecimal roundHalfAwayFromZero(BigDecimal p_bd, int p_iPrecision)
      Returns the closest scaled integer to the argument. Negative half values are rounded to the lower value.

      Examples:

       roundHalfAwayFromZero(0.0, 2)     ->    0.0
       roundHalfAwayFromZero(1.0, 2)     ->    1.0
       roundHalfAwayFromZero(-1.0, 2)    ->   -1.0
       roundHalfAwayFromZero(1.255, 2)   ->    1.26
       roundHalfAwayFromZero(-1.255, 2)  ->   -1.26
       roundHalfAwayFromZero(123.5, -2)  ->  100.0
       roundHalfAwayFromZero(-123.5, -2) -> -100.0
       

      Parameters:
      p_bd - The value to be rounded.
      p_iPrecision - The precision (may be a negative value).
      Returns:
      The rounded value.
    • roundHalfEven

      public double roundHalfEven(double p_dbl)
      Returns the closest integer to the argument. Half values are rounded to the neares even integer.

      Examples:

       roundHalfEven(0)     ->  0.0
       roundHalfEven(1)     ->  1.0
       roundHalfEven(-1)    -> -1.0
       roundHalfEven(0.5)   ->  0.0
       roundHalfEven(-0.5)  ->  0.0
       roundHalfEven(1.5)   ->  2.0
       roundHalfEven(-1.5)  -> -2.0
       roundHalfEven(0.12)  ->  0.0
       roundHalfEven(-0.12) ->  0.0
       roundHalfEven(0.62)  ->  1.0
       roundHalfEven(-0.62) -> -1.0
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • roundHalfEvenAsLong

      public long roundHalfEvenAsLong(double p_dbl)
      Returns the closest integer to the argument. Half values are rounded to the neares even integer.

      Examples:

       roundHalfEven(0)     ->  0
       roundHalfEven(1)     ->  1
       roundHalfEven(-1)    -> -1
       roundHalfEven(0.5)   ->  0
       roundHalfEven(-0.5)  ->  0
       roundHalfEven(1.5)   ->  2
       roundHalfEven(-1.5)  -> -2
       roundHalfEven(0.12)  ->  0
       roundHalfEven(-0.12) ->  0
       roundHalfEven(0.62)  ->  1
       roundHalfEven(-0.62) -> -1
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite, or less than Long.MIN_VALUE, or greater then Long.MAX_VALUE.
    • roundHalfEvenAsInt

      public int roundHalfEvenAsInt(double p_dbl)
      Returns the closest integer to the argument. Half values are rounded to the neares even integer.

      Examples:

       roundHalfEven(0)     ->  0
       roundHalfEven(1)     ->  1
       roundHalfEven(-1)    -> -1
       roundHalfEven(0.5)   ->  0
       roundHalfEven(-0.5)  ->  0
       roundHalfEven(1.5)   ->  2
       roundHalfEven(-1.5)  -> -2
       roundHalfEven(0.12)  ->  0
       roundHalfEven(-0.12) ->  0
       roundHalfEven(0.62)  ->  1
       roundHalfEven(-0.62) -> -1
       

      Parameters:
      p_dbl - The value to be rounded.
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite, or less than Integer.MIN_VALUE, or greater then Integer.MAX_VALUE.
    • roundHalfEven

      public double roundHalfEven(double p_dbl, int p_iPrecision)
      Returns the closest integer to the argument. Half values are rounded to the neares even integer.

      Examples:

       roundHalfEven(0, 2)       ->    0.0
       roundHalfEven(1, 2)       ->    1.0
       roundHalfEven(-1, 2)      ->   -1.0
       roundHalfEven(1.245, 2)   ->    1.24
       roundHalfEven(1.255, 2)   ->    1.26
       roundHalfEven(125.5, -2)  ->  100.0
       roundHalfEven(150, -2)    ->  200.0
       

      Parameters:
      p_dbl - The value to be rounded.
      p_iPrecision - The precision (may be a negative value).
      Returns:
      The rounded value.
      Throws:
      ArithmeticException - If the given value is NaN, or not finite.
    • roundHalfEven

      public BigDecimal roundHalfEven(BigDecimal p_bd)
      Returns the closest integer to the argument. Half values are rounded to the neares even integer.

      Examples:

       roundHalfEven(0)     ->  0.0
       roundHalfEven(1)     ->  1.0
       roundHalfEven(-1)    -> -1.0
       roundHalfEven(0.5)   ->  0.0
       roundHalfEven(-0.5)  ->  0.0
       roundHalfEven(1.5)   ->  2.0
       roundHalfEven(-1.5)  -> -2.0
       roundHalfEven(0.12)  ->  0.0
       roundHalfEven(-0.12) ->  0.0
       roundHalfEven(0.62)  ->  1.0
       roundHalfEven(-0.62) -> -1.0
       

      Parameters:
      p_bd - The value to be rounded.
      Returns:
      The rounded value.
    • roundHalfEven

      public BigDecimal roundHalfEven(BigDecimal p_bd, int p_iPrecision)
      Returns the closest scaled integer to the argument. Half values are rounded to the neares even scaled integer.

      Examples:

       roundHalfEven(0, 2)       ->    0.0
       roundHalfEven(1, 2)       ->    1.0
       roundHalfEven(-1, 2)      ->   -1.0
       roundHalfEven(1.245, 2)   ->    1.24
       roundHalfEven(1.255, 2)   ->    1.26
       roundHalfEven(125.5, -2)  ->  100.0
       roundHalfEven(150, -2)    ->  200.0
       

      Parameters:
      p_bd - The value to be rounded.
      p_iPrecision - The precision (may be a negative value).
      Returns:
      The rounded value.
    • add

      public Number add(Number p_numL, Number p_numR)
      Adds two numbers. This method does not check for range overflows.
      Parameters:
      p_numL - The first addend.
      p_numR - The second addend.
      Returns:
      The sum of the two values.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • sub

      public Number sub(Number p_numL, Number p_numR)
      Subtract two numbers. This method does not check for range overflows.
      Parameters:
      p_numL - The minuend.
      p_numR - The subtrahend.
      Returns:
      The difference of the two values.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • mult

      public Number mult(Number p_numL, Number p_numR)
      Multiplies two numbers. This method does not check for range overflows.
      Parameters:
      p_numL - The first factor.
      p_numR - The second factor.
      Returns:
      The product of the two factors.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • div

      public Number div(Number p_numL, Number p_numR)
      Divides one number by another. This method does not check for range overflows.
      Parameters:
      p_numL - The dividend.
      p_numR - The divisor.
      Returns:
      The quotient, or Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY if the divisor is 0.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • idiv

      public int idiv(Number p_numL, Number p_numR)
      Divides the int part of first number by the int part of the second.

      p_numA.intValue() / p_numB.intValue()

      This method does not check for range overflows.

      Parameters:
      p_numL - The dividend.
      p_numR - The divisor.
      Returns:
      The quotient.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
      Since:
      Intrexx 5.2.
    • ldiv

      public long ldiv(Number p_numL, Number p_numR)
      Divides the long part of first number by the long part of the second.

      p_numA.longValue() / p_numB.longValue()

      This method does not check for range overflows.

      Parameters:
      p_numL - The dividend.
      p_numR - The divisor.
      Returns:
      The quotient.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
      Since:
      Intrexx 5.2.
    • imod

      public int imod(Number p_numL, Number p_numR)
      Calculates the int part of first number modulo the int part of the second.

      p_numA.intValue() % p_numB.intValue()

      This method does not check for range overflows.

      Parameters:
      p_numL - The dividend.
      p_numR - The divisor.
      Returns:
      The remainder modulo p_numB.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
      Since:
      Intrexx 5.2.
    • lmod

      public long lmod(Number p_numL, Number p_numR)
      Calculates the long part of first number modulo the long part of the second.

      p_numA.intValue() % p_numB.intValue()

      This method does not check for range overflows.

      Parameters:
      p_numL - The dividend.
      p_numR - The divisor.
      Returns:
      The remainder modulo p_numB.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
      Since:
      Intrexx 5.2.
    • log

      public double log(Number p_num)
      Returns the natural logarithm (base e) of the given number as a double.
      Parameters:
      p_num - The numerus.
      Returns:
      The natural logarithm ln p_num.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • log10

      public double log10(Number p_num)
      Returns the logarithm to base 10 of the given number as a double.
      Parameters:
      p_num - The numerus.
      Returns:
      The logarithm log10 p_num.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • exp

      public double exp(Number p_numExponent)
      Returns Euler's number e raised to given power as a double.
      Parameters:
      p_numExponent - The exponent.
      Returns:
      The value ep_numExponent.
      Throws:
      IllegalArgumentException - If the given value is null.
    • pow

      public double pow(Number p_numBase, Number p_numExponent)
      Returns the value of the first argument raised to the power of the second argument as a double. This method does not check for range overflows.
      Parameters:
      p_numBase - The first factor.
      p_numExponent - The second factor.
      Returns:
      The value p_numBasep_numExponent.
      Throws:
      IllegalArgumentException - If either of the parameters is null.
    • getPI

      public double getPI()
      Get the value of π, i.e. 3.141592653589793.
      Returns:
      The value of π
      Since:
      Intrexx 6.0.
    • rad2deg

      public double rad2deg(Number p_num)
      Convert radians to degrees.
      deg = 180 / π * rad
      Parameters:
      p_num - The angle, in radians.
      Returns:
      The degree value of the given radian value.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • deg2rad

      public double deg2rad(Number p_num)
      Convert degrees to radians.
      rad = π / 180 * deg
      Returns:
      The radian value of the given degree value.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • ratio2rad

      public double ratio2rad(Number p_numNum, Number p_numDenom)
      Convert a ratio to radians.
      rad = 2 * π * nom / denom
      Parameters:
      p_numNum - The numerator, e.g. the arc length.
      p_numDenom - The denominator, e.g. the full circle.
      Returns:
      The radian value that corresponds to the given ratio.
      Throws:
      IllegalArgumentException - If one of the given values is null, or if the denominator is 0.
      Since:
      Intrexx 6.0.
    • sin

      public double sin(Number p_num)
      Get the trigonometric sine of the given angle.
      Parameters:
      p_num - The angle, in radians.
      Returns:
      The trigonometric sine of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • sinDeg

      public double sinDeg(Number p_num)
      Get the trigonometric sine of the given angle.
      Parameters:
      p_num - The angle, in degrees.
      Returns:
      The trigonometric sine of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • cos

      public double cos(Number p_num)
      Get the trigonometric cosine of the given angle.
      Parameters:
      p_num - The angle, in radians.
      Returns:
      The trigonometric cosine of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • cosDeg

      public double cosDeg(Number p_num)
      Get the trigonometric cosine of the given angle.
      Parameters:
      p_num - The angle, in degrees.
      Returns:
      The trigonometric cosine of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • tan

      public double tan(Number p_num)
      Get the trigonometric tangent of the given angle.
      Parameters:
      p_num - The angle, in radians.
      Returns:
      The trigonometric tangent of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • tanDeg

      public double tanDeg(Number p_num)
      Get the trigonometric tangent of the given angle.
      Parameters:
      p_num - The angle, in degrees.
      Returns:
      The trigonometric tangent of the given angle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • circleX

      public double circleX(Number p_numX, Number p_numRadius, Number p_numAngle)
      Calculate the x-coordinate of a point on a ellipse.
      circleX(x, r, φ) := x + r * cos(φ)
      Parameters:
      p_numX - An x offset.
      p_numRadius - The radius.
      p_numAngle - The angle, in radians.
      Returns:
      The x-coordinate of a point on the circle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • circleXInt

      public int circleXInt(Number p_numX, Number p_numRadius, Number p_numAngle)
      Calculate the x-coordinate of a point on a ellipse.
      circleX(x, r, φ) := x + r * cos(φ)
      Parameters:
      p_numX - An x offset.
      p_numRadius - The radius.
      p_numAngle - The angle, in radians.
      Returns:
      The x-coordinate of a point on the circle, rounded to the closest integer.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • circleX

      public double circleX(Number p_numX, Number p_numRadius, Number p_numNum, Number p_numDenom)
      Calculate the x-coordinate of a point on a ellipse.
      circleX(x, r, p, q) := x + r * cos(2 * π * p / q)
      Parameters:
      p_numX - An x offset.
      p_numRadius - The radius.
      p_numNum - The numerator, e.g. the arc length.
      p_numDenom - The denominator, e.g. the full circle.
      Returns:
      The x-coordinate of a point on the circle.
      Throws:
      IllegalArgumentException - If one of the given values is null, or if the denominator is 0.
      Since:
      Intrexx 6.0.
    • circleXInt

      public int circleXInt(Number p_numX, Number p_numRadius, Number p_numNum, Number p_numDenom)
      Calculate the x-coordinate of a point on a ellipse.
      circleX(x, r, p, q) := x + r * cos(2 * π * p / q)
      Parameters:
      p_numX - An x offset.
      p_numRadius - The radius.
      p_numNum - The numerator, e.g. the arc length.
      p_numDenom - The denominator, e.g. the full circle.
      Returns:
      The x-coordinate of a point on the circle, rounded to the closest integer.
      Throws:
      IllegalArgumentException - If one of the given values is null, or if the denominator is 0.
      Since:
      Intrexx 6.0.
    • circleY

      public double circleY(Number p_numY, Number p_numRadius, Number p_numAngle)
      Calculate the y-coordinate of a point on a ellipse.
      circleY(y, r, φ) := y + r * sin(φ)
      Parameters:
      p_numY - An y offset.
      p_numRadius - The radius.
      p_numAngle - The angle, in radians.
      Returns:
      The y-coordinate of a point on the circle.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • circleYInt

      public int circleYInt(Number p_numY, Number p_numRadius, Number p_numAngle)
      Calculate the y-coordinate of a point on a ellipse.
      circleY(y, r, φ) := y + r * sin(φ)
      Parameters:
      p_numY - An y offset.
      p_numRadius - The radius.
      p_numAngle - The angle, in radians.
      Returns:
      The y-coordinate of a point on the circle, rounded to the closest integer.
      Throws:
      IllegalArgumentException - If the given value is null.
      Since:
      Intrexx 6.0.
    • circleY

      public double circleY(Number p_numY, Number p_numRadius, Number p_numNum, Number p_numDenom)
      Calculate the y-coordinate of a point on a ellipse.
      circleY(y, r, p, q) := y + r * sin(2 * π * p / q)
      Parameters:
      p_numY - An y offset.
      p_numRadius - The radius.
      p_numNum - The numerator, e.g. the arc length.
      p_numDenom - The denominator, e.g. the full circle.
      Returns:
      The y-coordinate of a point on the circle.
      Throws:
      IllegalArgumentException - If one of the given values is null, or if the denominator is 0.
      Since:
      Intrexx 6.0.
    • circleYInt

      public int circleYInt(Number p_numY, Number p_numRadius, Number p_numNum, Number p_numDenom)
      Calculate the y-coordinate of a point on a ellipse.
      circleY(y, r, p, q) := y + r * sin(2 * π * p / q)
      Parameters:
      p_numRadius - The radius.
      p_numNum - The numerator, e.g. the arc length.
      p_numDenom - The denominator, e.g. the full circle.
      Returns:
      The y-coordinate of a point on the circle, rounded to the closest integer.
      Throws:
      IllegalArgumentException - If one of the given values is null, or if the denominator is 0.
      Since:
      Intrexx 6.0.
    • isNaN

      public boolean isNaN(float p_flt)
      Check if the specified number is a Not-a-Number (NaN) value.
      Parameters:
      p_flt - The number to check.
      Returns:
      true if the specified number is a Not-a-Number (NaN) value, or false otherwise.
    • isInfinite

      public boolean isInfinite(float p_flt)
      Check if the specified number is infinitely large in magnitude.
      Parameters:
      p_flt - The number to check.
      Returns:
      true if the specified number is infinitely large in magnitude, or false otherwise.
    • isNaN

      public boolean isNaN(double p_dbl)
      Check if the specified number is a Not-a-Number (NaN) value.
      Parameters:
      p_dbl - The number to check.
      Returns:
      true if the specified number is a Not-a-Number (NaN) value, or false otherwise.
    • isInfinite

      public boolean isInfinite(double p_dbl)
      Check if the specified number is infinitely large in magnitude.
      Parameters:
      p_dbl - The number to check.
      Returns:
      true if the specified number is infinitely large in magnitude, or false otherwise.
    • min

      public Number min(Number p_num1, Number p_num2)
      Determine the minimum of the given numbers.
      Parameters:
      p_num1 - The first number.
      p_num2 - The second number.
      Returns:
      The minimum of the two given numbers.
    • max

      public Number max(Number p_num1, Number p_num2)
      Determine the maximum of the given numbers.
      Parameters:
      p_num1 - The first number.
      p_num2 - The second number.
      Returns:
      The maximum of the two given numbers.
    • gt

      public boolean gt(Number p_numL, Number p_numR)
      Determine if the first number is greater than the second number.
      Parameters:
      p_numL - The first number.
      p_numR - The second number.
      Returns:
      true if the first number is greater than the second number, or false otherwise.
    • ge

      public boolean ge(Number p_numL, Number p_numR)
      Determine if the first number is greater or equal as the second number.
      Parameters:
      p_numL - The first number.
      p_numR - The second number.
      Returns:
      true if the first number is greater or equal as the second number, or false otherwise.
    • lt

      public boolean lt(Number p_numL, Number p_numR)
      Determine if the first number is less than the second number.
      Parameters:
      p_numL - The first number.
      p_numR - The second number.
      Returns:
      true if the first number is less than the second number, or false otherwise.
    • le

      public boolean le(Number p_numL, Number p_numR)
      Determine if the first number is less or equal the second number.
      Parameters:
      p_numL - The first number.
      p_numR - The second number.
      Returns:
      true if the first number is less or equal the second number, or false otherwise.
    • getRandomInt

      public int getRandomInt(int p_iMinValue, int p_iMaxValue)
      Parameters:
      p_iMinValue - The inclusive minimum value.
      p_iMaxValue - The exclusive maximum value.
      Returns:
      An integer random number r from the range p_iMinValue <= r < p_iMaxValue.
      Throws:
      IllegalArgumentException - - If p_iMaxValue < p_iMinValue.
    • getRandomLong

      public long getRandomLong(long p_lMinValue, long p_lMaxValue)
      Parameters:
      p_lMinValue - The inclusive minimum value.
      p_lMaxValue - The exclusive maximum value.
      Returns:
      An integer random number r from the range p_lMinValue <= r < p_lMaxValue.
      Throws:
      IllegalArgumentException - - If p_lMaxValue < p_lMinValue.