PrecisionEvaluate

Evaluates one or more string expressions using BigDecimal precision arithmetic.

If the results ends in an infinitely repeating decimal value only the first 20 digits of the decimal portion will be used. BigDecimal precision results only work with addition, subtraction, multiplication and division. The use of ^, MOD, % or \ arithmetic operators will result in normal integer precision.

Method Signature

PrecisionEvaluate(expressions=[string])

Arguments

Argument
Type
Required
Description
Default

expressions

string

true

Expressions to evaluate

Examples

precisionEvaluate of 1/3 plus 5

1/3 is calculated then 5 is added to the total. Display is limited to 20 threes.

Run Example

precisionEvaluate( 1 / 3 + 5 );

Result: 5.333333333333333333333333333333333

precisionEvaluate of 1/(7*12)

Calculate 1 divided by the product of 7 x 12

Run Example

precisionEvaluate( 1 / (7 * 12) );

Result: 0.0119047619047619047619047619047619

Additional Examples

dump( (59 + 10.99) * 100 ); // 6998.999999999999
dump( PrecisionEvaluate( "( 59+10.99 ) * 100" ) );
 // 6999

Last updated

Was this helpful?