Interface RealNumber

All Superinterfaces:
Comparable<RealNumber>, Number
All Known Subinterfaces:
AtLeast<N>, AtLeastEight, AtLeastEighteen, AtLeastEleven, AtLeastFifteen, AtLeastFive, AtLeastFour, AtLeastFourteen, AtLeastMinusOne, AtLeastNine, AtLeastNineteen, AtLeastOne, AtLeastSeven, AtLeastSeventeen, AtLeastSix, AtLeastSixteen, AtLeastTen, AtLeastThirteen, AtLeastThree, AtLeastTwelve, AtLeastTwenty, AtLeastTwo, AtLeastZero, AtMost<N>, AtMostEight, AtMostEighteen, AtMostEleven, AtMostFifteen, AtMostFive, AtMostFour, AtMostFourteen, AtMostMinusOne, AtMostNine, AtMostNineteen, AtMostOne, AtMostSeven, AtMostSeventeen, AtMostSix, AtMostSixteen, AtMostTen, AtMostThirteen, AtMostThree, AtMostTwelve, AtMostTwenty, AtMostTwo, AtMostZero, FourOrEight, Integer, IrrationalNumber<N>, NaturalNumber, NMinus1<N>, NPlus1<N>, PositiveInteger, RationalNumber
All Known Implementing Classes:
ConcreteNumber, Eight, Eighteen, Eleven, Fifteen, Five, Four, Fourteen, MinusOne, NegativeInfinity, Nine, Nineteen, One, PositiveInfinity, Seven, Seventeen, Six, Sixteen, Ten, Thirteen, Three, Twelve, Twenty, Two, Zero

public sealed interface RealNumber extends Number, Comparable<RealNumber> permits RationalNumber, IrrationalNumber<N>, NegativeInfinity, PositiveInfinity (not exhaustive)
A RealNumber is an element of the set of RealNumbers
  • Method Summary

    Modifier and Type
    Method
    Description
    default RealNumber
    abs()
    Returns this RealNumber's absolute value
    default boolean
    almostEquals(double n)
    Returns true if the given double value is almost equal to this RealNumber's double value where almost equal means that their absolute difference is less than FloatingPointMath#getMaxError()
    static boolean
    almostEquals(double n1, double n2)
    Returns true if the given double precision values are almost equal as defined by FloatingPointMath#getMaxError()
    default boolean
    Returns true if the given RealNumber is almost equal to this RealNumber where almost equal means that their absolute difference is less than FloatingPointMath.getRealMaxError()
    Returns this RealNumber's value as a BigDecimal
    default int
     
    default RealNumber
    Returns the quotient of dividing this RealNumber by the given RealNumber
    double
    Returns this RealNumber's value with double-precision type.
    default boolean
    Returns true if this RealNumber is greater than the given RealNumber, false otherwise
    default boolean
    Returns true if this RealNumber is greater than or equal to the given RealNumber, false otherwise
    boolean
    Determines if this RealNumber's value has the precision of a primitive double
    default boolean
    Returns true if this RealNumber is less than the given RealNumber, false otherwise
    default boolean
    Returns true if this RealNumber is less than or equal to the given RealNumber, false otherwise
    default RealNumber
    Returns the difference between this RealNumber and the given RealNumber
    default RealNumber
    Returns the remainder of dividing this RealNumber by the given RealNumber
    static RealNumber
    of(double d)
    Creates a new RealNumber for the given double precision value
    static RealNumber
    of(BigDecimal number)
    Creates a new RealNumber for the given BigInteger value
    default RealNumber
    Returns the sum of this RealNumber and the given RealNumber
    default RealNumber
    pow(RealNumber exponent)
    Returns the product of exponentiating this RealNumber by the given RealNumber
    default RealNumber
    Returns the product of multiplying this RealNumber by the given RealNumber
    default RealNumber
    Truncates this RealNumber toward ZERO
  • Method Details

    • doubleValue

      double doubleValue()
      Returns this RealNumber's value with double-precision type. Note that the value will be an approximation for irrational numbers such as Pi, Phi, e or repeating decimals such as 0.666..., 1.851851851..., etc.
      Returns:
      the double value that is the closest approximation to this real number
    • bigDecimalValue

      BigDecimal bigDecimalValue()
      Returns this RealNumber's value as a BigDecimal
      Returns:
      the BigDecimal value
    • isDouble

      boolean isDouble()
      Determines if this RealNumber's value has the precision of a primitive double
      Returns:
      true if this RealNumber is double precision, false, if BigDecimal precision
    • plus

      default RealNumber plus(RealNumber n)
      Returns the sum of this RealNumber and the given RealNumber
      Parameters:
      n - the number to add to this one
      Returns:
      the sum of this number and the given number
    • minus

      default RealNumber minus(RealNumber n)
      Returns the difference between this RealNumber and the given RealNumber
      Parameters:
      n - the number to subtract from this one
      Returns:
      the difference of this number and the given number
    • times

      default RealNumber times(RealNumber n)
      Returns the product of multiplying this RealNumber by the given RealNumber
      Parameters:
      n - the factor to multiple by
      Returns:
      the product of real numbers
    • dividedBy

      default RealNumber dividedBy(RealNumber n)
      Returns the quotient of dividing this RealNumber by the given RealNumber
      Parameters:
      n - the number to divide this number by
      Returns:
      the quotient of dividing this number by the given number
    • modulo

      default RealNumber modulo(RealNumber n)
      Returns the remainder of dividing this RealNumber by the given RealNumber
      Parameters:
      n - the number to modulo by
      Returns:
      the remainder of this number divided by the given number
    • abs

      default RealNumber abs()
      Returns this RealNumber's absolute value
      Returns:
      this number's absolute value
    • pow

      default RealNumber pow(RealNumber exponent)
      Returns the product of exponentiating this RealNumber by the given RealNumber
      Parameters:
      exponent - the exponent
      Returns:
      the exponential product of this number by the given exponent
    • truncate

      default RealNumber truncate()
      Truncates this RealNumber toward ZERO
      Returns:
      a real number rounded toward 0
    • lessThan

      default boolean lessThan(RealNumber n)
      Returns true if this RealNumber is less than the given RealNumber, false otherwise
      Parameters:
      n - the real number to test
      Returns:
      the truth of this number being less than the given number
    • lessThanOrEqualTo

      default boolean lessThanOrEqualTo(RealNumber n)
      Returns true if this RealNumber is less than or equal to the given RealNumber, false otherwise
      Parameters:
      n - the real number to test
      Returns:
      the truth of this number being less than or equal to the given number
    • greaterThan

      default boolean greaterThan(RealNumber n)
      Returns true if this RealNumber is greater than the given RealNumber, false otherwise
      Parameters:
      n - the real number to test
      Returns:
      the truth of this number being greater than the given number
    • greaterThanOrEqualTo

      default boolean greaterThanOrEqualTo(RealNumber n)
      Returns true if this RealNumber is greater than or equal to the given RealNumber, false otherwise
      Parameters:
      n - the real number to test
      Returns:
      the truth of this number being greater than or equal to the given number
    • almostEquals

      default boolean almostEquals(RealNumber n)
      Returns true if the given RealNumber is almost equal to this RealNumber where almost equal means that their absolute difference is less than FloatingPointMath.getRealMaxError()
      Parameters:
      n - the number to compare
      Returns:
      true if the number is nearly equal to this one, false otherwise
    • almostEquals

      default boolean almostEquals(double n)
      Returns true if the given double value is almost equal to this RealNumber's double value where almost equal means that their absolute difference is less than FloatingPointMath#getMaxError()
      Parameters:
      n - the number to compare
      Returns:
      true if the number is nearly equal to this one, false otherwise
    • almostEquals

      static boolean almostEquals(double n1, double n2)
      Returns true if the given double precision values are almost equal as defined by FloatingPointMath#getMaxError()
      Parameters:
      n1 - the first number
      n2 - the second number
      Returns:
      true if the numbers are almost equal, false otherwise
    • compareTo

      default int compareTo(RealNumber n)
      Specified by:
      compareTo in interface Comparable<RealNumber>
    • of

      static RealNumber of(double d)
      Creates a new RealNumber for the given double precision value
      Parameters:
      d - the double value
      Returns:
      a RealNumber for the value d
    • of

      static RealNumber of(BigDecimal number)
      Creates a new RealNumber for the given BigInteger value
      Parameters:
      number - the double value
      Returns:
      a RealNumber for the number