> 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/advanced-calculation.md).

# Advanced Calculation

## Description

This part allows application users to enter a mathematical expression for calculation. In contrast to the calculation part, the calculation-1-1 part support large numbers (digits > 16).

## 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.

## Editor Fields

| Field Name  | Description/Use                                                                                                                                                                                                  | Type/Options | Optional/Mandatory |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ |
| Dataobject  | This is the data object in which the system will store the result of the calculation.                                                                                                                            | Data Object  | Mandatory          |
| Decimals    | This is the number of decimals the system should display in the result.                                                                                                                                          | Integer      | Mandatory          |
| Round       | This specifies whether the system should round the result to the number of decimals specified above. If the end user selects "No" the system will truncate the result to the number of decimals specified above. | Yes \| No    | Optional           |
| Calculation | This is the mathematical expression the system should use to perform the calculation.                                                                                                                            | Text         | Mandatory          |

## Mathematical Expressions

Mathematical expressions can consist of 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: **abs, ceil, floor, avg, min, max, exp, log, log10, log2, sin, cos, tan, asin, acos, atan, pow, deg, rad, sqrt, mod, PI, comp**

**comp** With v7.4, LogicNets added a new function called 'comp'. The syntax for comp(\<number 1>, \<number 2>), returns the following:

1 : when number 1 is larger than number 2 0 : when number 1 and number 2 are equal -1 : when number 1 is smaller than number 2

**min, max** The min- and max- functions take a comma separated list of numbers to return the largest, smallest out of the list. E.g. min(2, -7, 3) ==> -7

**pow** The pow-function takes two arguments e.g. pow(a, b) to perform ab

**PI** is the constant π and can for example be used in the gonometric functions like: cos(PI/4) ==> 0.70710678118655

**mod** The mod-function takes two arguments e.g. mod(3, 2) ==> 1

## Using Data Variables and Default Values

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

In support of interpolation, a default value can be defined in case of the variable being undefined. This should be used in most situations to prevent a calculation error and warning message during runtime. 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

The inclusion of variables for default values is also possible as follows

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

**Sample Mathematical Expressions (decimals = 2, round = yes)**

(400000000000000000000000000 - 8) \* 3 ==> 1199999999999999999999999976.00

(400000000000000000000000000 - 8.2562321) ==> 399999999999999999999999991.74

## 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/advanced-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/advanced-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.
