Class FloatingPoint

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static FloatingPoint NaN
      The Not-a-Number instance (unique).
      static FloatingPoint ONE
      The floating point instance representing the multiplicative identity.
      static FloatingPoint ZERO
      The floating point instance representing the additive identity.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FloatingPoint abs()
      Returns the absolute value of this floating point number.
      int compareTo​(FloatingPoint that)
      Compares two floating point number numerically.
      FloatingPoint copy()
      Returns a copy of this number allocated by the calling thread (possibly on the stack).
      FloatingPoint divide​(FloatingPoint that)
      Returns this floating point number divided by the one specified.
      double doubleValue()
      Returns the value of this floating point number as a double.
      boolean equals​(java.lang.Object that)
      Compares this floating point number against the specified object.
      static int getDigits()
      Returns the local number of digits used during calculations (default 20 digits).
      int getExponent()
      Returns the decimal exponent.
      LargeInteger getSignificand()
      Returns the significand value.
      int hashCode()
      Returns the hash code for this floating point number.
      FloatingPoint inverse()
      Returns the inverse of this floating point number.
      boolean isLargerThan​(FloatingPoint that)
      Compares the absolute value of two FloatingPoint numbers.
      boolean isNaN()
      Indicates if this floating point is Not-a-Number.
      boolean isNegative()
      Indicates if this rational number is less than zero.
      boolean isPositive()
      Indicates if this floating point number is greater than zero.
      boolean isZero()
      Indicates if this floating point number is equal to zero.
      long longValue()
      Returns the value of this floating point number as a long.
      FloatingPoint minus​(FloatingPoint that)
      Returns the difference between this FloatingPoint number and the one specified.
      FloatingPoint opposite()
      Returns the opposite of this floating point number.
      FloatingPoint plus​(FloatingPoint that)
      Returns the sum of this floating point number with the one specified.
      LargeInteger round()
      Returns the closest integer to this floating point number.
      static void setDigits​(int digits)
      Sets the local number of digits to be used during calculations.
      FloatingPoint sqrt()
      Returns the square root of this floating point number.
      FloatingPoint times​(long multiplier)
      Returns the product of this floating point number with the specified long multiplier.
      FloatingPoint times​(FloatingPoint that)
      Returns the product of this floating point number with the one specified.
      javolution.text.Text toText()
      Returns the decimal text representation of this number.
      static FloatingPoint valueOf​(double doubleValue)
      Returns the floating point number for the specified double value (convenience method).
      static FloatingPoint valueOf​(long longValue)
      Returns the floating point number for the specified long value (convenience method).
      static FloatingPoint valueOf​(long significand, int exponent)
      Returns the floating point number for the specified long significand and power of two exponent (convenience method).
      static FloatingPoint valueOf​(java.lang.CharSequence chars)
      Returns the floating point number for the specified character sequence.
      static FloatingPoint valueOf​(LargeInteger significand, int exponent)
      Returns the floating point number for the specified LargeInteger significand and power of two exponent.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ZERO

        public static final FloatingPoint ZERO
        The floating point instance representing the additive identity.
      • ONE

        public static final FloatingPoint ONE
        The floating point instance representing the multiplicative identity.
      • NaN

        public static final FloatingPoint NaN
        The Not-a-Number instance (unique).
    • Method Detail

      • valueOf

        public static FloatingPoint valueOf​(LargeInteger significand,
                                            int exponent)
        Returns the floating point number for the specified LargeInteger significand and power of two exponent.
        Parameters:
        significand - the significand value.
        exponent - the power of two exponent.
        Returns:
        (significand · 2exponent
      • valueOf

        public static FloatingPoint valueOf​(long significand,
                                            int exponent)
        Returns the floating point number for the specified long significand and power of two exponent (convenience method).
        Parameters:
        significand - the significand value.
        exponent - the power of two exponent.
        Returns:
        (significand · 2exponent
      • valueOf

        public static FloatingPoint valueOf​(long longValue)
        Returns the floating point number for the specified long value (convenience method).
        Parameters:
        longValue - the long value.
        Returns:
        FloatingPoint.valueOf(longValue, 0)
      • valueOf

        public static FloatingPoint valueOf​(double doubleValue)
        Returns the floating point number for the specified double value (convenience method).
        Parameters:
        doubleValue - the double value.
        Returns:
        FloatingPoint.valueOf(longValue, 0)
      • valueOf

        public static FloatingPoint valueOf​(java.lang.CharSequence chars)
        Returns the floating point number for the specified character sequence. The number of digits
        Parameters:
        chars - the character sequence.
        Returns:
        the corresponding FloatingPoint number.
      • getDigits

        public static int getDigits()
        Returns the local number of digits used during calculations (default 20 digits).
        Returns:
        the number of digits.
      • setDigits

        public static void setDigits​(int digits)
        Sets the local number of digits to be used during calculations.
        Parameters:
        digits - the number of digits.
        Throws:
        java.lang.IllegalArgumentException - if digits <= 0
      • getExponent

        public int getExponent()
        Returns the decimal exponent.
        Returns:
        this floating point decimal exponent.
      • round

        public LargeInteger round()
        Returns the closest integer to this floating point number.
        Returns:
        this floating point rounded to the nearest integer.
      • minus

        public FloatingPoint minus​(FloatingPoint that)
        Returns the difference between this FloatingPoint number and the one specified.
        Overrides:
        minus in class Number<FloatingPoint>
        Parameters:
        that - the floating point number to be subtracted.
        Returns:
        this - that.
      • times

        public FloatingPoint times​(long multiplier)
        Returns the product of this floating point number with the specified long multiplier.
        Parameters:
        multiplier - the long multiplier.
        Returns:
        this · multiplier.
      • divide

        public FloatingPoint divide​(FloatingPoint that)
        Returns this floating point number divided by the one specified.
        Parameters:
        that - the FloatingPoint number divisor.
        Returns:
        this / that.
        Throws:
        java.lang.ArithmeticException - if that.equals(ZERO)
      • abs

        public FloatingPoint abs()
        Returns the absolute value of this floating point number.
        Returns:
        |this|.
      • sqrt

        public FloatingPoint sqrt()
        Returns the square root of this floating point number.
        Returns:
        the positive square root of this floating point number.
      • isZero

        public boolean isZero()
        Indicates if this floating point number is equal to zero.
        Returns:
        this == 0
      • isPositive

        public boolean isPositive()
        Indicates if this floating point number is greater than zero.
        Returns:
        this > 0
      • isNegative

        public boolean isNegative()
        Indicates if this rational number is less than zero.
        Returns:
        this < 0
      • isNaN

        public boolean isNaN()
        Indicates if this floating point is Not-a-Number.
        Returns:
        true if this number has unbounded value; false otherwise.
      • toText

        public javolution.text.Text toText()
        Returns the decimal text representation of this number.
        Specified by:
        toText in interface javolution.lang.Realtime
        Specified by:
        toText in class Number<FloatingPoint>
        Returns:
        the text representation of this number.
      • equals

        public boolean equals​(java.lang.Object that)
        Compares this floating point number against the specified object.
        Specified by:
        equals in class Number<FloatingPoint>
        Parameters:
        that - the object to compare with.
        Returns:
        true if the objects are the same; false otherwise.
      • longValue

        public long longValue()
        Returns the value of this floating point number as a long.
        Specified by:
        longValue in class Number<FloatingPoint>
        Returns:
        the numeric value represented by this floating point after conversion to type long.
      • doubleValue

        public double doubleValue()
        Returns the value of this floating point number as a double.
        Specified by:
        doubleValue in class Number<FloatingPoint>
        Returns:
        the numeric value represented by this FloatingPoint after conversion to type double.
      • compareTo

        public int compareTo​(FloatingPoint that)
        Compares two floating point number numerically.
        Specified by:
        compareTo in interface java.lang.Comparable<FloatingPoint>
        Specified by:
        compareTo in class Number<FloatingPoint>
        Parameters:
        that - the floating point number to compare with.
        Returns:
        -1, 0 or 1 as this FloatingPoint number is numerically less than, equal to, or greater than that.
      • copy

        public FloatingPoint copy()
        Description copied from class: Number
        Returns a copy of this number allocated by the calling thread (possibly on the stack).
        Specified by:
        copy in interface javolution.lang.ValueType
        Specified by:
        copy in class Number<FloatingPoint>
        Returns:
        an identical and independant copy of this number.