Class BigIntegerToRationalDecorator

  • All Implemented Interfaces:
    FieldI, java.io.Serializable

    public class BigIntegerToRationalDecorator
    extends FieldDecorator
    Converts BigIntegers, Long, Integer and Short to Rationals on input. Optionally on output if the rational number represents an integer then convert it back to a BigInteger.

    This should be use to wrap an RationalField. Problems will occur if combined with an IntegerField as the IntegerField will convert a fraction like "5/2" into integer division giving a result of the integer 2. Instead to mix Rationals and BigIntegers use

         RationalField rf = new RationalField();
         BigIntegerToRationalDecorator ird = new BigIntegerToRationalDecorator(rf,true);
         FieldOperatorTable fot = new FieldOperatorTable(ird);
         BigIntegerNumberFactory inf = new BigIntegerNumberFactory();
         Jep jep = new Jep(fot,inf);
     
    which performing all calculations in rationals and converts results to BigInteger if possible.

    To mix Integers and Rationals use

         RationalField rf = new RationalField();
         BigIntegerToRationalDecorator ird = new BigIntegerToRationalDecorator(rf,true);
         IntegerToBigIntegerDecorator ibid = new IntegerToBigIntegerDecorator(ird,true);
         FieldOperatorTable fot = new FieldOperatorTable(ibid);
         IntegerNumberFactory inf = new IntegerNumberFactory();
         Jep jep = new Jep(fot,inf);
     
    See Also:
    Serialized Form
    • Constructor Detail

      • BigIntegerToRationalDecorator

        public BigIntegerToRationalDecorator​(FieldI field)
      • BigIntegerToRationalDecorator

        public BigIntegerToRationalDecorator​(FieldI field,
                                             boolean simplifyResults)