Package org.codehaus.groovy.runtime.typehandling

# Class BigIntegerMath

java.lang.Object
org.codehaus.groovy.runtime.typehandling.NumberMath
org.codehaus.groovy.runtime.typehandling.BigIntegerMath

public final class BigIntegerMath extends NumberMath
Arbitrary-precision integer arithmetic operations.

Singleton instance providing NumberMath implementations for BigInteger-based operations. Supports exact integer arithmetic without overflow, with support for all bitwise operations.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final BigIntegerMath`
  `INSTANCE`
  Singleton instance of BigIntegerMath.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Number`
  `absImpl(Number number)`
  Computes the absolute value of a number.
  `Number`
  `addImpl(Number left, Number right)`
  Adds two numbers.
  `Number`
  `andImpl(Number left, Number right)`
  Bitwise AND of two numbers.
  `Number`
  `bitwiseNegateImpl(Number left)`
  Bitwise negation of a number.
  `int`
  `compareToImpl(Number left, Number right)`
  Compares two numbers.
  `Number`
  `divideImpl(Number left, Number right)`
  Divides two numbers.
  `Number`
  `intdivImpl(Number left, Number right)`
  Integer division of two numbers.
  `Number`
  `leftShiftImpl(Number left, Number right)`
  Left shift of a number.
  `Number`
  `modImpl(Number left, Number right)`
  Modulo of two numbers.
  `Number`
  `multiplyImpl(Number left, Number right)`
  Multiplies two numbers.
  `Number`
  `orImpl(Number left, Number right)`
  Bitwise OR of two numbers.
  `Number`
  `remainderImpl(Number left, Number right)`
  Remainder of two numbers.
  `Number`
  `rightShiftImpl(Number left, Number right)`
  Right shift of a number.
  `Number`
  `subtractImpl(Number left, Number right)`
  Subtracts two numbers.
  `Number`
  `unaryMinusImpl(Number left)`
  Negates a number.
  `Number`
  `unaryPlusImpl(Number left)`
  Returns the number as-is (unary plus/identity).
  `Number`
  `xorImpl(Number left, Number right)`
  Bitwise XOR of two numbers.

  ### Methods inherited from class org.codehaus.groovy.runtime.typehandling.NumberMath

  `abs, add, and, bitwiseNegate, compareTo, createUnsupportedException, divide, getMath, intdiv, isBigDecimal, isBigInteger, isByte, isFloatingPoint, isInteger, isLong, isShort, leftShift, mod, multiply, or, remainder, rightShift, rightShiftUnsigned, rightShiftUnsignedImpl, subtract, toBigDecimal, toBigInteger, unaryMinus, unaryPlus, xor`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INSTANCE

    public static final BigIntegerMath INSTANCE
    Singleton instance of BigIntegerMath.

- ## Method Details

  - ### absImpl

    public Number absImpl(Number number)
    Description copied from class: `NumberMath`
    Computes the absolute value of a number.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `absImpl` in class `NumberMath`
    Parameters:
      `number` - the operand
    Returns:
      the absolute value

  - ### addImpl

    public Number addImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Adds two numbers.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `addImpl` in class `NumberMath`
    Parameters:
      `left` - the left operand
      `right` - the right operand
    Returns:
      the sum

  - ### subtractImpl

    public Number subtractImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Subtracts two numbers.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `subtractImpl` in class `NumberMath`
    Parameters:
      `left` - the minuend
      `right` - the subtrahend
    Returns:
      the difference

  - ### multiplyImpl

    public Number multiplyImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Multiplies two numbers.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `multiplyImpl` in class `NumberMath`
    Parameters:
      `left` - the first multiplicand
      `right` - the second multiplicand
    Returns:
      the product

  - ### divideImpl

    public Number divideImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Divides two numbers.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `divideImpl` in class `NumberMath`
    Parameters:
      `left` - the dividend
      `right` - the divisor
    Returns:
      the quotient

  - ### compareToImpl

    public int compareToImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Compares two numbers.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `compareToImpl` in class `NumberMath`
    Parameters:
      `left` - the first number
      `right` - the second number
    Returns:
      negative, zero, or positive as left is less than, equal to, or greater than right

  - ### intdivImpl

    public Number intdivImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Integer division of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting integer division must override.

    Overrides:
      `intdivImpl` in class `NumberMath`
    Parameters:
      `left` - the dividend
      `right` - the divisor
    Returns:
      the integer quotient

  - ### modImpl

    public Number modImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Modulo of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting modulo must override.

    Overrides:
      `modImpl` in class `NumberMath`
    Parameters:
      `left` - the dividend
      `right` - the divisor
    Returns:
      the modulo result

  - ### remainderImpl

    public Number remainderImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Remainder of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting remainder must override.

    Overrides:
      `remainderImpl` in class `NumberMath`
    Parameters:
      `left` - the dividend
      `right` - the divisor
    Returns:
      the remainder

  - ### unaryMinusImpl

    public Number unaryMinusImpl(Number left)
    Description copied from class: `NumberMath`
    Negates a number.

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `unaryMinusImpl` in class `NumberMath`
    Parameters:
      `left` - the operand
    Returns:
      the negation

  - ### unaryPlusImpl

    public Number unaryPlusImpl(Number left)
    Description copied from class: `NumberMath`
    Returns the number as-is (unary plus/identity).

    Subclasses must implement this method according to type promotion hierarchy rules.

    Specified by:
      `unaryPlusImpl` in class `NumberMath`
    Parameters:
      `left` - the operand
    Returns:
      the same value

  - ### bitwiseNegateImpl

    public Number bitwiseNegateImpl(Number left)
    Description copied from class: `NumberMath`
    Bitwise negation of a number.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bitwise operations must override.

    Overrides:
      `bitwiseNegateImpl` in class `NumberMath`
    Parameters:
      `left` - the operand
    Returns:
      the bitwise negation

  - ### orImpl

    public Number orImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Bitwise OR of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bitwise operations must override.

    Overrides:
      `orImpl` in class `NumberMath`
    Parameters:
      `left` - the first operand
      `right` - the second operand
    Returns:
      the bitwise OR result

  - ### andImpl

    public Number andImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Bitwise AND of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bitwise operations must override.

    Overrides:
      `andImpl` in class `NumberMath`
    Parameters:
      `left` - the first operand
      `right` - the second operand
    Returns:
      the bitwise AND result

  - ### xorImpl

    public Number xorImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Bitwise XOR of two numbers.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bitwise operations must override.

    Overrides:
      `xorImpl` in class `NumberMath`
    Parameters:
      `left` - the first operand
      `right` - the second operand
    Returns:
      the bitwise XOR result

  - ### leftShiftImpl

    public Number leftShiftImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Left shift of a number.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bit shifting must override.

    Overrides:
      `leftShiftImpl` in class `NumberMath`
    Parameters:
      `left` - the value to shift
      `right` - the shift distance
    Returns:
      the left-shifted value

  - ### rightShiftImpl

    public Number rightShiftImpl(Number left, Number right)
    Description copied from class: `NumberMath`
    Right shift of a number.

    Default implementation throws UnsupportedOperationException. Subclasses supporting bit shifting must override.

    Overrides:
      `rightShiftImpl` in class `NumberMath`
    Parameters:
      `left` - the value to shift
      `right` - the shift distance
    Returns:
      the right-shifted value