java.lang.Object
java.lang.Number
com.singularsys.extensions.field.implementations.Rational
All Implemented Interfaces:
Serializable, Comparable<Rational>

public class Rational extends Number implements Comparable<Rational>
A rational number represented as the quotient of two BigIntegers. An immutable type.

Note if using Rational numbers with the PrintVisitor a special rule RationalDivisionPrintRule is needed to ensure divisions are correctly printed. This can be added with

 jep.getPrintVisitor().addSpecialRule(jep.getOperatorTable().getDivide(),
                        new RationalDivisionPrintRule());
 
See Also:
  • Field Details

    • ZERO

      public static final Rational ZERO
    • ONE

      public static final Rational ONE
    • TWO

      public static final Rational TWO
    • MINUSONE

      public static final Rational MINUSONE
    • HALF

      public static final Rational HALF
  • Constructor Details

    • Rational

      public Rational()
      Zero
    • Rational

      public Rational(int numerator, int denominator)
      Create a rational number
      Parameters:
      numerator - number on bottom of fraction
      denominator - number on top of fraction
    • Rational

      public Rational(int numerator)
    • Rational

      public Rational(BigInteger num, BigInteger denom)
    • Rational

      public Rational(long numerator)
    • Rational

      public Rational(BigInteger val)
    • Rational

      public Rational(long numerator2, long denominator2)
      Constructor with two longs.
      Parameters:
      numerator2 -
      denominator2 -
      Since:
      Jep 4.1 extensions 2.2
  • Method Details