public IValue log(INumber x, INumber base) { try { return x.toReal().log(base.toReal(), values.getPrecision()); } catch (ArithmeticException ae) { throw RuntimeExceptionFactory.arithmeticException(ae.getMessage(), null, null); } }
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 pow(INumber x, IInteger y) { try { return x.toReal().pow(y); } catch (ArithmeticException ae) { throw RuntimeExceptionFactory.arithmeticException(ae.getMessage(), null, null); } }
public IValue nroot(INumber x, IInteger y) { try { return x.toReal().nroot(y, values.getPrecision()); } catch (ArithmeticException ae) { throw RuntimeExceptionFactory.arithmeticException(ae.getMessage(), null, null); } }
public IValue toString(INumber d) // @doc{toString -- convert a real to a string.} { return values.string(d.toString()); }
public IValue toReal(INumber n) // @doc{toReal -- convert a number value to a real value.} { return n.toReal(); }
public IValue toInt(INumber d) // @doc{toInteger -- convert a real to integer.} { return d.toInteger(); }
public IValue round(INumber d) { return d.toReal().round().toInteger(); }
public IValue precision(INumber x, IInteger precision) { return values.real(x.toString(), precision.intValue()); }