Class MathTool

All Implemented Interfaces:
ITool, IVariable, Serializable, Cloneable

@OpenApiAll public class MathTool extends Tool
Provide basic numeric operations for report.
Since:
Jun 6, 2008
See Also:
  • Constructor Details

    • MathTool

      public MathTool()
  • Method Details

    • abs

      public static int abs(int a)
      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:
      a - the argument whose absolute value is to be determined
      Returns:
      the absolute value of the argument.
    • abs

      public static double abs(double a)
      Returns the absolute value of an 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:
      a - the argument whose absolute value is to be determined
      Returns:
      the absolute value of the argument.
    • ceil

      public static double ceil(double a)
      Returns the smallest (closest to negative infinity) 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:
      a - a 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 static double floor(double a)
      Returns the largest (closest to positive infinity) 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:
      a - a 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.
    • max

      public static int max(int a, int b)
      Returns the greater of two int values. If the arguments have the same value, the result is that same value.
      Parameters:
      a - an argument.
      b - another argument.
      Returns:
      the larger of a and b.
    • max

      public static double max(double a, double b)
      Returns the greater of two double values. If the arguments have the same value, the result is that same value.
      Parameters:
      a - an argument.
      b - another argument.
      Returns:
      the larger of a and b.
    • min

      public static int min(int a, int b)
      Returns the smaller of two int values. If the arguments have the same value, the result is that same value.
      Parameters:
      a - an argument.
      b - another argument.
      Returns:
      the smaller of a and b.
    • min

      public static double min(double a, double b)
      Returns the smaller of two double values. If the arguments have the same value, the result is that same value.
      Parameters:
      a - an argument.
      b - another argument.
      Returns:
      the smaller of a and b.
    • round

      public static long round(double a)
      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.
      Parameters:
      a - a floating-point value to be rounded to a long.
      Returns:
      the value of the argument rounded to the nearest long value.