Package gnu.math

Class Numeric

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Quantity

public abstract class Numeric extends Number
See Also:
  • Field Details

    • FLOOR

      public static final int FLOOR
      See Also:
    • CEILING

      public static final int CEILING
      See Also:
    • TRUNCATE

      public static final int TRUNCATE
      See Also:
    • ROUND

      public static final int ROUND
      See Also:
    • NONNEG_MOD

      public static final int NONNEG_MOD
      Rounding mode to always produce a non-negative remainder. Like FLOOR if the divisor is non-negative; CEILING otherwise. Used to implement R6RS's div/mod operators.
      See Also:
  • Constructor Details

    • Numeric

      public Numeric()
  • Method Details

    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • add

      public abstract Numeric add(Object obj, int k)
      Return this + k * obj.
    • add

      public final Numeric add(Object obj)
    • sub

      public final Numeric sub(Object obj)
    • mul

      public abstract Numeric mul(Object obj)
    • div

      public abstract Numeric div(Object obj)
    • abs

      public abstract Numeric abs()
    • neg

      public abstract Numeric neg()
    • toString

      public abstract String toString(int radix)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asNumericOrNull

      public static Numeric asNumericOrNull(Object value)
    • isExact

      public abstract boolean isExact()
    • toExact

      public Numeric toExact()
    • toInexact

      public Numeric toInexact()
    • isZero

      public abstract boolean isZero()
    • compare

      public int compare(Object obj)
      Return an integer for which of this or obj is larger. Return 1 if this>obj; 0 if this==obj; -1 if this<obj; -2 if this!=obj otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
    • compareReversed

      public int compareReversed(Numeric x)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • grt

      public boolean grt(Object x)
    • geq

      public boolean geq(Object x)
    • addReversed

      public Numeric addReversed(Numeric x, int k)
      Calculate x+k&this.
    • mulReversed

      public Numeric mulReversed(Numeric x)
    • divReversed

      public Numeric divReversed(Numeric x)
    • div_inv

      public Numeric div_inv()
      Return the multiplicative inverse.
    • mul_ident

      public Numeric mul_ident()
      Return the multiplicative identity.
    • power

      public Numeric power(IntNum y)
      Return this raised to an integer power. Implemented by repeated squaring and multiplication. If y < 0, returns div_inv of the result.