Class NumberMath

java.lang.Object
org.checkerframework.common.value.util.NumberMath

public final class NumberMath extends Object
Performs Java numeric operations whose left operand is a boxed number.
  • Method Details

    • getNumberMath

      public static NumberMath getNumberMath(Number number)
      Returns an arithmetic helper for number.
      Parameters:
      number - a number
      Returns:
      an arithmetic helper
      Throws:
      UnsupportedOperationException - if number is not a supported boxed primitive
    • plus

      public Number plus(Number right)
      Returns this + right.
      Parameters:
      right - the right operand
      Returns:
      this + right
    • minus

      public Number minus(Number right)
      Returns this - right.
      Parameters:
      right - the right operand
      Returns:
      this - right
    • times

      public Number times(Number right)
      Returns this * right.
      Parameters:
      right - the right operand
      Returns:
      this * right
    • divide

      public @Nullable Number divide(Number right)
      Returns this / right, or null if right is zero and the operation is integer division.
      Parameters:
      right - the right operand
      Returns:
      this / right, or null if right is zero and the operation is integer division
    • remainder

      public @Nullable Number remainder(Number right)
      Returns this % right, or null if right is zero and the operation is integer remainder.
      Parameters:
      right - the right operand
      Returns:
      this % right, or null if right is zero and the operation is integer remainder
    • shiftLeft

      public Number shiftLeft(Number right)
      Returns this << right.
      Parameters:
      right - the right operand
      Returns:
      this << right
    • signedShiftRight

      public Number signedShiftRight(Number right)
      Returns this >> right.
      Parameters:
      right - the right operand
      Returns:
      this >> right
    • unsignedShiftRight

      public Number unsignedShiftRight(Number right)
      Returns this >>> right.
      Parameters:
      right - the right operand
      Returns:
      this >>> right
    • bitwiseAnd

      public Number bitwiseAnd(Number right)
      Returns this & right.
      Parameters:
      right - the right operand
      Returns:
      this & right
    • bitwiseOr

      public Number bitwiseOr(Number right)
      Returns this | right.
      Parameters:
      right - the right operand
      Returns:
      this | right
    • bitwiseXor

      public Number bitwiseXor(Number right)
      Returns this ^ right.
      Parameters:
      right - the right operand
      Returns:
      this ^ right
    • unaryPlus

      public Number unaryPlus()
      Returns +this.
      Returns:
      +this
    • unaryMinus

      public Number unaryMinus()
      Returns -this.
      Returns:
      -this
    • bitwiseComplement

      public Number bitwiseComplement()
      Returns ~this.
      Returns:
      ~this
    • equalTo

      public Boolean equalTo(Number right)
      Returns this == right.
      Parameters:
      right - the right operand
      Returns:
      this == right
    • notEqualTo

      public Boolean notEqualTo(Number right)
      Returns this != right.
      Parameters:
      right - the right operand
      Returns:
      this != right
    • greaterThan

      public Boolean greaterThan(Number right)
      Returns this > right.
      Parameters:
      right - the right operand
      Returns:
      this > right
    • greaterThanEq

      public Boolean greaterThanEq(Number right)
      Returns this >= right.
      Parameters:
      right - the right operand
      Returns:
      this >= right
    • lessThan

      public Boolean lessThan(Number right)
      Returns this < right.
      Parameters:
      right - the right operand
      Returns:
      this < right
    • lessThanEq

      public Boolean lessThanEq(Number right)
      Returns this <= right.
      Parameters:
      right - the right operand
      Returns:
      this <= right
    • isIntegralZero

      public static boolean isIntegralZero(Number number)
      Returns whether number is an integral zero.
      Parameters:
      number - a number
      Returns:
      whether number is an integral zero