> For the complete documentation index, see [llms.txt](https://docs.digia.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digia.tech/logic-and-interaction/adding-logic/math-operators.md).

# Math Operators

#### There are various Math operators support on PIM's Dashboard

* <mark style="color:blue;">**Addition Operator**</mark> <kbd><mark style="color:blue;">(sum)<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Multiply Operator**</mark> <kbd><mark style="color:blue;">(mul)<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Subtraction Operator**</mark><kbd><mark style="color:blue;">(diff)<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Divide Operator**</mark><kbd><mark style="color:blue;">(divide)<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Modulo Operator**</mark> <kbd><mark style="color:blue;">( modulo )<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Ceil Operator**</mark> <kbd><mark style="color:blue;">( ceil )<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Floor Operator**</mark> <kbd><mark style="color:blue;">( floor )<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**Absolute Operator**</mark> <kbd><mark style="color:blue;">( abs )<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**clamp Operator**</mark> <kbd><mark style="color:blue;">( clamp )<mark style="color:blue;"></kbd>
* <mark style="color:blue;">**numberFormat Operator**</mark>

#### 1. Addition Operator (sum)

when you want to sum couple of numbers than you can use sum operator

#### Arguments

This Operator can take upto 255 arguments

#### Example

```javascript
sum(1,2,4); //this will return 7 as output
```

#### 2. Multiply Operator (mul)

when you want to multiply couple of numbers than you can use multiply operator

#### Arguments

This Operator can take upto 255 arguments

#### Example

```javascript
mul(1,2,4); //this will return 8 as output
```

#### 3. Subtraction Operator (diff)

used to perform subtraction operation

#### `Arguments`

This operator will take two arguments and both arguments are required

#### Example

```javascript
diff(5,2); 
// this will return 3 as output
// Explanation: 5-2 = 3
```

#### 4. Divide Operator (divide)

used to perform divide mathematical operation

#### Arguments

This operator will take two arguments and both arguments are required

#### Example

```javascript
divide(4,2); 
// this will return 2 as output
// Explanation: 4/2 = 2
```

#### 5 . Modulo operator

Returns the remainder of division of first number by second

#### Arguments

This operator will take two number arguments

#### Example

```javascript
modulo(5,2)
//it will return 1 as 5 divided by 2 leaves
// a remainder of 1
```

#### 6 . Ceil operator

Rounds a number up to the nearest integer

#### Arguments

It will take one number argument

#### Example

```javascript
ceil(4.5)
//it will output 5 as it is nearest up integer
```

#### 7. Floor Operator

Rounds a number down to the nearest integer

#### Arguements

it will take one number arguement

#### Exampe

```javascript
floor(4.5)
//it will output 4 as it is the nearest down integer
```

#### 8 . Absolute Operator

Returns the absolute value of a number

{% stepper %}
{% step %}
**Create a page state**

for this example we created a page state variable var of type number
{% endstep %}

{% step %}
**Enter an initial value to your state**

we entered -10 as our intial value for our page state
{% endstep %}
{% endstepper %}

#### Argument

it will take a page state arguement

<pre class="language-javascript"><code class="lang-javascript">abs(var)
<strong>//var = -10
</strong>//it will output 10,the absolute value of -10
</code></pre>

#### 9 . Clamp Operator

Restricts a value to be within the specified range \[min, max]

Argument

```javascript
 clamp(10,6,8)
//it will return 8 as 10 is out of bounds
```

#### 10 . number format

Formats a number using the specified format. Defaults to '##,##,###

#### Arguments

requires a number and a format

#### Example

```javascript
numberFormat(9883928872, '##,##,##')
//it will output 98,83,92,88,72
```


---

# 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://docs.digia.tech/logic-and-interaction/adding-logic/math-operators.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.
