use of com.googlecode.aviator.runtime.type.AviatorDouble in project aviatorscript by killme2008.
the class MathPowFunction method call.
@Override
public AviatorObject call(final Map<String, Object> env, final AviatorObject arg1, final AviatorObject arg2) {
Number left = FunctionUtils.getNumberValue(arg1, env);
Number right = FunctionUtils.getNumberValue(arg2, env);
if (TypeUtils.isBigInt(left)) {
return new AviatorBigInt(((BigInteger) left).pow(right.intValue()));
} else if (TypeUtils.isDecimal(left)) {
return new AviatorDecimal(((BigDecimal) left).pow(right.intValue(), RuntimeUtils.getMathContext(env)));
} else {
return new AviatorDouble(Math.pow(left.doubleValue(), right.doubleValue()));
}
}
use of com.googlecode.aviator.runtime.type.AviatorDouble in project aviatorscript by killme2008.
the class RandomFunctionUnitTest method testCall.
@Test
public void testCall() {
RandomFunction rand = new RandomFunction();
AviatorObject result = rand.call(null);
assertTrue(result instanceof AviatorDouble);
assertFalse(result.getValue(null).equals(rand.call(null)));
}
Aggregations