> For the complete documentation index, see [llms.txt](https://docs.uniot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uniot.io/platform/sandbox/visual-editor/math.md).

# Math

Math blocks provide numerical operations and calculations for your scripts. Use these blocks to perform arithmetic, apply mathematical functions, and manipulate numeric values from sensors or variables.

## value

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-f95e11d0b78139bc38e694626ffce4dd370284e9%2Fmath_value.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

A numeric constant. Use this block to provide fixed numbers for calculations, comparisons, or as parameters to other blocks.

**Parameters:**

* **Value** (Number): Enter any numeric value (integers or decimals)

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-ad6c824e49529a83464248d061b6bc8e0e5181f8%2Fmath_value_example.svg?alt=media" alt=""><figcaption><p>Define temperature thresholds</p></figcaption></figure>

## math operation

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-34c44ea706ab3cad4e228ab9a63386417d71976c%2Fmath_operation.png?alt=media" alt="" width="138"><figcaption></figcaption></figure></div>

Applies a single-value mathematical operation. Choose from absolute value (removes sign) or negation (flips positive to negative and vice versa).

**Parameters:**

* **Operation**: Select `abs` (absolute value) or `-` (negate)
* **Value** (Number): The number to operate on

**Returns:**

* **Number**: The result of the operation

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-bec27b4d6bf9160151a6d51d6c67b52b2a222ad5%2Fmath_operation_example.svg?alt=media" alt=""><figcaption><p>Temperature difference calculation</p></figcaption></figure>

## arithmetic

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-12e57f7bab39883c7a073fa740e2c5a92289fe97%2Fmath_arithmetic.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

Performs basic arithmetic operations between two numbers.

**Parameters:**

* **Left Value** (Number): The first number
* **Operator**: Choose `+` (add), `-` (subtract), `×` (multiply), `÷` (divide), `^` (power)
* **Right Value** (Number): The second number

**Returns:**

* **Number**: The result of the calculation

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-97404438299cab0bb770d54d6b1077c3232c687a%2Fmath_arithmetic_example.svg?alt=media" alt=""><figcaption><p>Convert raw sensor value to voltage</p></figcaption></figure>

## number condition

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-433ce33776d51b4f0f56b9a27f63b2b85471bd77%2Fmath_number_condition.png?alt=media" alt="" width="193"><figcaption></figcaption></figure></div>

Checks whether a number meets a specific condition. Use this for pattern detection or periodic actions.

**Parameters:**

* **Value** (Number): The number to check
* **Condition**: Select `even`, `odd`, `positive`, `negative`, `whole`, `divisible by`

**Returns:**

* **Boolean**: `#t` (true) if the condition is met, `()` (false) otherwise

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-f540f5601b49995de2d96e56a587d7554d2d98c8%2Fmath_number_condition_example.svg?alt=media" alt=""><figcaption><p>Read sensor value every 5th script execution</p></figcaption></figure>

## remainder

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-5cc3a3aa2fd6c42157bfdcef47a25dd97dbae463%2Fmath_remainder.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

Calculates the remainder after dividing one number by another (modulo operation). Useful for creating repeating patterns or detecting multiples.

**Parameters:**

* **Dividend** (Number): The number to be divided
* **Divisor** (Number): The number to divide by

**Returns:**

* **Number**: The remainder of the division

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-acfce49a2fc414f66852cfd65ee12d559f1406e2%2Floops_iterator_example.svg?alt=media" alt=""><figcaption><p>Alternate on/off pattern for multiple LEDs</p></figcaption></figure>
