public IValue precision(INumber x) { if (x.getType().isIntegerType()) { IInteger k = (IInteger) x; return values.integer(k.toReal().precision()); } if (x.getType().isRationalType()) { IRational k = (IRational) x; return values.integer(k.toReal().precision()); } return values.integer(((IReal) x).precision()); }
public IValue scale(INumber x) { try { if (x.getType().isIntegerType()) { IInteger k = (IInteger) x; return values.integer(k.toReal().scale()); } if (x.getType().isRationalType()) { IRational k = (IRational) x; return values.integer(k.toReal().scale()); } return values.integer(((IReal) x).scale()); } catch (ArithmeticException ae) { throw RuntimeExceptionFactory.arithmeticException(ae.getMessage(), null, null); } }
public IValue denominator(IRational n) { return n.denominator(); }
public IValue toInt(IRational n) // @doc{toReal -- convert a rational value to a integer value.} { return n.toInteger(); }
public IValue toReal(IRational n) // @doc{toReal -- convert a rational value to a real value.} { return n.toReal(); }
public IValue remainder(IRational n) { return n.remainder(); }
public IValue numerator(IRational n) { return n.numerator(); }