Package gnu.math

Class IntFraction

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Comparable

    public class IntFraction
    extends RatNum
    implements java.io.Externalizable
    Implementation of exact rational numbers a ratio of two IntNums.
    See Also:
    Serialized Form
    • Constructor Detail

      • IntFraction

        public IntFraction​(IntNum num,
                           IntNum den)
    • Method Detail

      • isNegative

        public final boolean isNegative()
        Specified by:
        isNegative in class RealNum
      • sign

        public final int sign()
        Description copied from class: RealNum
        Return 1 if >0; 0 if ==0; -1 if <0; -2 if NaN.
        Specified by:
        sign in class RealNum
      • compare

        public final int compare​(java.lang.Object obj)
        Description copied from class: Numeric
        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).
        Overrides:
        compare in class Complex
      • add

        public Numeric add​(java.lang.Object y,
                           int k)
        Description copied from class: Numeric
        Return this + k * obj.
        Specified by:
        add in class RealNum
      • mul

        public Numeric mul​(java.lang.Object y)
        Specified by:
        mul in class RealNum
      • div

        public Numeric div​(java.lang.Object y)
        Specified by:
        div in class RealNum
      • doubleValue

        public double doubleValue()
        Description copied from class: Quantity
        The value of the real component, as a double. This is relative to the unit().dims - i.e. unit()/doubleValue() is factored in.
        Overrides:
        doubleValue in class Quaternion
      • toString

        public java.lang.String toString​(int radix)
        Overrides:
        toString in class Complex
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException