> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/numeric-calculation.md).

# Numeric Calculation

## Description

This part allows application users to enter a mathematical expression so the system can perform a calculation.

## Use

The calculation part is used by entering the requested mathematical expression in the part. The system stores the calculated result in the defined data object. This part is recommended for any formula-based math., especially when working with integers. It will correctly handle decimals but does not have built-in rounding. Two alternatives are to use a [**format variable**](/release-9/platform-documentation/process-node-parts/format-data-object-format-variable-report-item.md) part on the result, or to use a calculation to round to the required number of decimals (see Tips below).

The **advanced calculation** part has all the same functionality below but also

1. works with "large numbers" (> 16 digits) as well as more common numbers with fewer digits
2. has a parameter for rounding (such that you just specify the number of decimal places). The article for this part can be found [here](/release-9/platform-documentation/process-node-parts/advanced-calculation.md).

## Editor Fields

| Field Name                   | Description/Use                                                                                                                                                                                                                                                           | Type/Options | Optional/Mandatory |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ |
| Data object                  | This is the name of the data object in which the system will store the result of the calculation.                                                                                                                                                                         | Data Object  | Mandatory          |
| Group                        | This is the path of the data object.                                                                                                                                                                                                                                      | Data Object  | Optional           |
| Calculation                  | <p>This is where the user enters the mathematical expression for the system to perform.<br><strong>When using data objects from the application, use $(my\_var:0) syntax.</strong><br>(To avoid runtime errors it is important to specify default values - see below)</p> | Text         | Mandatory          |
| <p>Round to<br>(v7.4 on)</p> | <p>When filled in, the numeric calculation will be rounded to the specified number of decimal places.<br>When left empty, no rounding is performed on the calculation.</p>                                                                                                | Number       | Optional           |

Mathematical expressions can include the following elements:

* numbers (whole and floating using ‘.’ as decimal point)
* standard operators, such as +, -, /, \*, ^
* parentheses to control the precedence of the operators
* mathematical functions: **sqrt**, **abs, ceil, floor, exp, log, log10, max, min, mod, cos, acos, sin, asin, tan**

The function **max** returns the maximum value of its numeric arguments, and the **min** function computes the minimum value. Both can be used with an unlimited number of arguments.

The function **mod** is equivalent to the % operator.

For trigonometric functions, angles are expressed in degrees.

### Using Data Variables from the Model

Mathematical expressions can also include interpolated text , such as **$(my\_var)**.

In support of interpolation, a default value can be defined in case the variable itself has not yet been defined by the runtime logicnets. Default values should be used in most scenarios to prevent a calculation error or warning message during runtime.

### Default Values

Default values are specified inside the () and after a colon as follows.

**$(my\_var:0)** gives a result of 0 if my\_var is NULL **$(my\_var:1)** gives a result of 1 if my\_var is NULL

### Sample Mathematical Expressions

sqrt(100) ==> 10

(4 – 8) \* 3 ==> -12

abs(4-8)\*3 ==> 12

ceil (2.6) ==> 3

floor (2.6) ==> 2

exp(1) ==> 2.71828

log(100) ==> 4.6051

log10(100) ==> 2

max(14, 2, 100) ==> 100

min(14, 2, 100) ==> 2

sin(90) ==> 1

asin(1) ==> 90

cos(90) ==> 6.123233995736766e-017

acos(0) ==> 90

tan(45) ==> 0.9999999999999999

## Tips & Tricks

If you are using this part, but need to round a number to a given number of decimals mid-stream, it may not be appropriate to switch to the advanced calculation process node to access the rounding parameter. Instead you can use a mathematical expression to round.

ROUNDED to r places = floor ( \[your-variable] \* 10^r + 0.5) / 10^r

* Example: 3.14159 rounded = floor (3.14159 x 100 +0.5) / 100 = floor (314.5556) / 100 = 314 / 100 = 3.14
* Example: 8/3 rounded to 1 decimal place = floor (2.666666r \* 10 + 0.5) / 10 = floor (27.166666.r ) / 10 = 27 / 10 = 2.7

In other words, we multiply then add 0.5 to round up, use floor to remove the excess digits beyond the number we want, and then divide to get back to the order of magnitude we started with.

## Example

For an example form in which you can enter a mathematical expression the system will pass to the calculation part, download and import the following [sample project](/release-9/example-gallery/example-projects-for-parts/numeric-calculation-example-project.md) in your workspace.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/numeric-calculation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
