Utility class for performing exact arithmetic operations with overflow checking.

Methods

  • Returns the sum of the two arguments; throwing an exception if the result overflows a long integer.

    Parameters

    • x: number

      The first value

    • y: number

      The second value

    Returns number

    The result of adding the two values

    ArithmeticError if the result overflows a long integer

  • Returns the floor division of the two arguments; throwing an exception if the result overflows a long integer.

    Parameters

    • x: number

      The dividend

    • y: number

      The divisor

    Returns number

    The quotient of dividing the two values rounded towards positive infinity.

  • Returns the remainder of the floor division of the two arguments; throwing an exception if the result overflows a long integer.

    Parameters

    • x: number

      The dividend

    • y: number

      The divisor

    Returns number

    The remainder of dividing the two values rounded towards positive infinity.

  • Returns the product of the two arguments; throwing an exception if the result overflows a long integer.

    Parameters

    • x: number

      The first value

    • y: number

      The second value

    Returns number

    The result of multiplying the two values

    ArithmeticError if the result overflows a long integer

  • Returns the difference of the two arguments; throwing an exception if the result overflows a long integer.

    Parameters

    • x: number

      The first value

    • y: number

      The second value

    Returns number

    The result of subtracting the two values

    ArithmeticError if the result overflows a long integer