public class BigIntegerToRationalDecorator extends FieldDecorator
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);
Constructor and Description |
---|
BigIntegerToRationalDecorator(FieldI field) |
BigIntegerToRationalDecorator(FieldI field,
boolean simplifyResults) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
convertInput(java.lang.Object in)
Converts BigInteger, Integer, Long and Short to Rational.
|
java.lang.Object |
convertOutput(java.lang.Object out)
If possible convert Rationals to BigIntegers.
|
public BigIntegerToRationalDecorator(FieldI field)
public BigIntegerToRationalDecorator(FieldI field, boolean simplifyResults)
public java.lang.Object convertInput(java.lang.Object in) throws EvaluationException
convertInput
in class FieldDecorator
in
to a different type, otherwise return in
.EvaluationException
public java.lang.Object convertOutput(java.lang.Object out) throws EvaluationException
convertOutput
in class FieldDecorator
out
to a different type, otherwise return out
.EvaluationException
Copyright © 2018 Singular Systems http://www.singularsys.com/jep