Package gnu.math

Class RealNum

    • Constructor Detail

      • RealNum

        public RealNum()
    • Method Detail

      • re

        public final RealNum re()
        Description copied from class: Quantity
        The value of the real component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true real component.
        Overrides:
        re in class Quantity
      • im

        public final RealNum im()
        Description copied from class: Quantity
        The value of the imaginary component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true imaginary component.
        Overrides:
        im in class Quantity
      • isReal

        public static boolean isReal​(Object value)
      • asRealNumOrNull

        public static RealNum asRealNumOrNull​(Object value)
      • isNegative

        public abstract boolean isNegative()
      • classifyFinite

        public int classifyFinite()
        Description copied from class: Complex
        Check if value is finite, infinite, or NaN.
        Overrides:
        classifyFinite in class Complex
        Returns:
        1 if finite; 0 if infinite; -1 if NaN.
      • sign

        public abstract int sign()
        Return 1 if >0; 0 if ==0; -1 if <0; -2 if NaN.
      • add

        public abstract Numeric add​(Object obj,
                                    int k)
        Description copied from class: Numeric
        Return this + k * obj.
        Overrides:
        add in class Complex
      • isZero

        public boolean isZero()
        Overrides:
        isZero in class Complex
      • toExact

        public RatNum toExact()
        Convert to an exact number. Implements the Scheme inexact->exact (for real numbers).
        Overrides:
        toExact in class Complex
      • toInt

        public static double toInt​(double d,
                                   int rounding_mode)
        Converts a real to an integer, according to a specified rounding mode. Note an inexact argument gives an inexact result, following Scheme. See also RatNum.toExactInt.
      • toInt

        public RealNum toInt​(int rounding_mode)
        Converts a real to an integer, according to a specified rounding mode. Note an inexact argument gives an inexact result, following Scheme. See also toExactInt.
      • toExactInt

        public IntNum toExactInt​(int rounding_mode)
        Converts to an exact integer, with specified rounding mode.
      • toExactInt

        public static IntNum toExactInt​(double value,
                                        int rounding_mode)
        Converts real to an exact integer, with specified rounding mode.
      • toExactInt

        public static IntNum toExactInt​(double value)
        Converts an integral double (such as a toInt result) to an IntNum.
      • toScaledInt

        public static IntNum toScaledInt​(double f,
                                         int k)
        Convert double to (rounded) integer, after multiplying by 10**k.
      • toScaledInt

        public static IntNum toScaledInt​(RatNum r,
                                         int k)
        Convert rational to (rounded) integer, after multiplying by 10**k.
      • toScaledInt

        public IntNum toScaledInt​(int k)
        Convert this to (rounded) integer, after multiplying by 10**k.
      • compareTo

        public int compareTo​(Object o)
        Implements the Comparable interface. This ordering isn't fully consistent with equals, since say it returns 0 when comparing 1.5 and 3/2, though they are not equals.
        Specified by:
        compareTo in interface Comparable
      • toStringScientific

        public static String toStringScientific​(float d)
      • toStringScientific

        public static String toStringScientific​(double d)
      • toStringScientific

        public static String toStringScientific​(String dstr)
        Convert result of Double.toString or Float.toString to scientific notation. Does not validate the input.
      • toStringScientific

        public static int toStringScientific​(String dstr,
                                             StringBuffer sbuf)
      • toStringDecimal

        public static String toStringDecimal​(String dstr)