# 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-b8a353abc0997df13cc2e44779b6d83ea8e40868%2Fmath_value.png?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-cd1a74f9b6ea4b6c971f3eacc4ea3024b65c6fce%2Fmath_value_example.png?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-170556b77107c901bcefcbf1b64420bc433a0913%2Fmath_operation.png?alt=media" alt=""><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-0982e4ff6ca3e5ea92c13099dba8d0a12bdf2ace%2Fmath_operation_example.png?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-2f0a44e0fe1914ac2fa5709be3fa097dfd8fa064%2Fmath_arithmetic.png?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-8969150ac3444d2e51ea2c687854598b5d29dfc8%2Fmath_arithmetic_example.png?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-9f0324efb4afc26cc6aa27a6c2fb35db551df687%2Fmath_number_condition.png?alt=media" alt=""><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-a0d343310c6013689816ed5e1ee214ae0572ddaf%2Fmath_number_condition_example.png?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-b63dcc77786824e6fc2d29ce68cafc764e7436cf%2Fmath_remainder.png?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-e88d3cac06952fc3ea101d3308d202f8da7443e5%2Floops_iterator_example.png?alt=media" alt=""><figcaption><p>Alternate on/off pattern for multiple LEDs</p></figcaption></figure>
