use of com.googlecode.aviator.runtime.type.AviatorDecimal 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()));
}
}
Aggregations