Example #1
0
 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);
   }
 }
Example #2
0
 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());
 }
Example #3
0
 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);
   }
 }
Example #4
0
 public IValue pow(INumber x, IInteger y) {
   try {
     return x.toReal().pow(y);
   } catch (ArithmeticException ae) {
     throw RuntimeExceptionFactory.arithmeticException(ae.getMessage(), null, null);
   }
 }
Example #5
0
 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);
   }
 }
Example #6
0
 public IValue toString(INumber d)
       // @doc{toString -- convert a real to a string.}
     {
   return values.string(d.toString());
 }
Example #7
0
 public IValue toReal(INumber n)
       // @doc{toReal -- convert a number value to a real value.}
     {
   return n.toReal();
 }
Example #8
0
 public IValue toInt(INumber d)
       // @doc{toInteger -- convert a real to integer.}
     {
   return d.toInteger();
 }
Example #9
0
 public IValue round(INumber d) {
   return d.toReal().round().toInteger();
 }
Example #10
0
 public IValue precision(INumber x, IInteger precision) {
   return values.real(x.toString(), precision.intValue());
 }