> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/modularity/evaluating-code/reference/built-in-functions/precisionevaluate.md).

# PrecisionEvaluate

Evaluates one or more string expressions dynamically from left to right using BigDecimal precision arithmetic.

Note, this is provided for compat. It acutally works the same as evaluate() and will use the same high precision math setting that Boxlang is configured with. BoxLang will always use high precision math by default.

## Method Signature

```
PrecisionEvaluate(expression=[string])
```

### Arguments

| Argument     | Type     | Required | Description                                                | Default |
| ------------ | -------- | -------- | ---------------------------------------------------------- | ------- |
| `expression` | `string` | `true`   | Expression to evaluate. String expressions can be complex. |         |

## Examples

## Description

Evaluates one or more string expressions dynamically from left to right, using BigDecimal precision arithmetic to calculate arbitrary-precision arithmetic expressions.

## Returns

An object containing the result of the evaluations. The result is the value returned by the rightmost expression.

## Category

Mathematical functions, Dynamic evaluation functions

## Function Syntax

```java
precisionEvaluate( string_expression1 [, string_expression2, ... ] )
```

## Parameters

| Parameter                                       | Description                                                                                                                                                   |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `string_expression1`, `string_expression2`, ... | Expressions to evaluate. Expressions are evaluated from left to right, and the result of an expression on the left can be used by an expression on the right. |

## Usage

`precisionEvaluate` calculates arbitrarily long decimal values using BigDecimal precision arithmetic. BigDecimal arithmetic accepts and generates decimal numbers of any length without using exponential notation.

Precision arithmetic applies to addition, subtraction, multiplication, and division. Exponentiation (`^`), modulus (`MOD` or `%`), and integer division use normal integer or floating-point arithmetic instead of returning BigDecimal values.

This function differs from `evaluate` in its use of BigDecimal precision arithmetic. If an expression contains a single- or double-quotation mark, the mark must be escaped. If an expression such as `1/3` results in an infinitely repeating decimal value, the decimal portion is limited to 20 digits.

For better processing efficiency, do not put arithmetic expressions in quotation marks. `precisionEvaluate( a * b )` compiles more efficiently than `precisionEvaluate( "a * b" )`, although both forms produce the same result.

## Example

```java
num1 = 5;
num2 = 3 / 8;
writeOutput( "The resultant expression is: " & precisionEvaluate( num1 / num2 ) );
```

Output:

```
The resultant expression is: 13.33333333333333333333
```

## Additional 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](https://try.boxlang.io/?code=eJwrKEpNzizOzM9zLUvMKU0sSdVQMFTQVzBW0FYwVdC05gIAu0AJTQ%3D%3D)

```java
precisionEvaluate( 1 / 3 + 5 );

```

Result: 5.333333333333333333333333333333333

### precisionEvaluate of 1/(7\*12)

Calculate 1 divided by the product of 7 x 12

[Run Example](https://try.boxlang.io/?code=eJwrKEpNzizOzM9zLUvMKU0sSdVQMFTQV9AwV9BSMDTSVNC05gIA2IoJzw%3D%3D)

```java
precisionEvaluate( 1 / (7 * 12) );

```

Result: 0.0119047619047619047619047619047619

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

```

## Related

* [Evaluate](/boxlang-framework/modularity/evaluating-code/reference/built-in-functions/evaluate.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/modularity/evaluating-code/reference/built-in-functions/precisionevaluate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
