Class RationalBigInt

  • All Implemented Interfaces:
    Num

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

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

    • Field Detail

      • value

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

        private Num POSITIVE_INFINITY
      • NEGATIVE_INFINITY

        private Num NEGATIVE_INFINITY
      • NaN

        private Num NaN
      • ZERO

        private Num ZERO
    • Constructor Detail

      • RationalBigInt

        private RationalBigInt()
      • RationalBigInt

        public RationalBigInt​(int num)
      • RationalBigInt

        public RationalBigInt​(double value)
      • RationalBigInt

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

        private RationalBigInt​(java.math.BigInteger num,
                               java.math.BigInteger den)
      • RationalBigInt

        private RationalBigInt​(org.apache.commons.math3.fraction.BigFraction frac)
    • Method Detail

      • doubleValue

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

        public org.apache.commons.math3.fraction.BigFraction 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