Class RationalInt

  • All Implemented Interfaces:
    Num

    public class RationalInt
    extends java.lang.Object
    implements Num
    Wrapper class around org.apache.commons.math3.fraction.Fraction introducing special values like positive / negative infinity and NaN as well as operators like min, max, ==, >, >=, <, and <= that are not part of Fraction but needed by the network calculator.

    For the ease of converting from the primitive data type double to Fraction objects, copy by value semantic are is applied.

    • Field Detail

      • value

        private org.apache.commons.math3.fraction.Fraction value
      • POSITIVE_INFINITY

        private Num POSITIVE_INFINITY
      • NEGATIVE_INFINITY

        private Num NEGATIVE_INFINITY
      • NaN

        private Num NaN
      • ZERO

        private Num ZERO
    • Constructor Detail

      • RationalInt

        private RationalInt()
      • RationalInt

        public RationalInt​(int num)
      • RationalInt

        public RationalInt​(double value)
      • RationalInt

        public RationalInt​(int num,
                           int den)
      • RationalInt

        private RationalInt​(org.apache.commons.math3.fraction.Fraction frac)
    • Method Detail

      • getInstance

        public static RationalInt getInstance()
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in interface Num
      • getValue

        public org.apache.commons.math3.fraction.Fraction getValue()
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface Num
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface Num
        Overrides:
        toString in class java.lang.Object
      • copy

        public Num copy()
        Specified by:
        copy in interface Num
      • getNaN

        public Num getNaN()
        Specified by:
        getNaN in interface Num
      • createNaN

        public Num createNaN()
        Specified by:
        createNaN in interface Num
      • getZero

        public Num getZero()
        Specified by:
        getZero in interface Num
      • createZero

        public Num createZero()
        Specified by:
        createZero in interface Num
      • create

        public Num create​(int num)
        Specified by:
        create in interface Num
      • create

        public Num create​(double value)
        Specified by:
        create in interface Num
      • create

        public Num create​(int num,
                          int den)
        Specified by:
        create in interface Num
      • create

        public Num create​(java.lang.String num_str)
                   throws java.lang.Exception
        Specified by:
        create in interface Num
        Throws:
        java.lang.Exception
      • gtZero

        public boolean gtZero()
        Specified by:
        gtZero in interface Num
      • geqZero

        public boolean geqZero()
        Specified by:
        geqZero in interface Num
      • eqZero

        public boolean eqZero()
        Specified by:
        eqZero in interface Num
      • leqZero

        public boolean leqZero()
        Specified by:
        leqZero in interface Num
      • ltZero

        public boolean ltZero()
        Specified by:
        ltZero in interface Num
      • gt

        public boolean gt​(Num num)
        Specified by:
        gt in interface Num
      • geq

        public boolean geq​(Num num)
        Specified by:
        geq in interface Num
      • eq

        public boolean eq​(Num num)
        Specified by:
        eq in interface Num
      • eq

        public boolean eq​(double num)
        Specified by:
        eq in interface Num
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface Num
        Overrides:
        equals in class java.lang.Object
      • leq

        public boolean leq​(Num num)
        Specified by:
        leq in interface Num
      • lt

        public boolean lt​(Num num)
        Specified by:
        lt in interface Num
      • isFinite

        public boolean isFinite()
        Specified by:
        isFinite in interface Num
      • isInfinite

        public boolean isInfinite()
        Specified by:
        isInfinite in interface Num
      • isNaN

        public boolean isNaN()
        Specified by:
        isNaN in interface Num
      • add

        public Num add​(Num num1,
                       Num num2)
        Specified by:
        add in interface Num
      • sub

        public Num sub​(Num num1,
                       Num num2)
        Specified by:
        sub in interface Num
      • mult

        public Num mult​(Num num1,
                        Num num2)
        Specified by:
        mult in interface Num
      • div

        public Num div​(Num num1,
                       Num num2)
        Specified by:
        div in interface Num
      • abs

        public Num abs​(Num num)
        Specified by:
        abs in interface Num
      • diff

        public Num diff​(Num num1,
                        Num num2)
        Specified by:
        diff in interface Num
      • max

        public Num max​(Num num1,
                       Num num2)
        Specified by:
        max in interface Num
      • min

        public Num min​(Num num1,
                       Num num2)
        Specified by:
        min in interface Num
      • negate

        public Num negate​(Num num)
        Specified by:
        negate in interface Num