# Math

> Add, average, round, and compare numbers.

Built-in step · 10 steps. Web page: https://docs.lodol.com/docs/integrations/built-in/math

## Steps

### Calculate absolute value

Get a number without its minus sign, for example -5 becomes 5.

**Inputs**

- Number (`value`, number, required): The number to drop the minus sign from.

**Outputs**: The number without its minus sign.

**Example output**

```json
5.25
```

### Calculate average

Calculate the average of a list of numbers.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to average. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The average of the numbers in the list, or blank if it has none.

**Example output**

```json
2.5
```

### Calculate total

Add up all numbers in a list.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to add up. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The sum of the numbers in the list, or 0 if it is empty.

**Example output**

```json
1234.5
```

### Find maximum value

Find the largest number in a list.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to look through. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The largest number in the list, or blank if it has none.

**Example output**

```json
199.99
```

### Find middle value

Find the middle value of a list of numbers. For an even-length list, the two middle values are averaged.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to find the middle of. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The middle number once the list is sorted, or the average of the two middle numbers when the list has an even count. Blank if the list has no numbers.

**Example output**

```json
2.5
```

### Find minimum value

Find the smallest number in a list.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to look through. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The smallest number in the list, or blank if it has none.

**Example output**

```json
12.5
```

### Find most common number

Find the number that appears most often in a list.

**Inputs**

- Numbers (`values`, list, required): The list of numbers to look through. Text like "12.50" counts as a number, and blank items are skipped.

**Outputs**: The number that appears most often in the list. In a tie, the one that appears first. Blank if the list has no numbers.

**Example output**

```json
4.5
```

### Find the standard deviation

Measure how spread out a list of numbers is: close to 0 when they are all alike, larger the more they vary. The same as STDEV in a spreadsheet.

**Inputs**

- Numbers (`values`, list, required): The list of numbers. Text like 12.50 counts, and blanks are skipped.
- The numbers are (`basis`, text): A sample of a larger group (STDEV, the usual choice), or the whole group (STDEV.P). One of: `sample` (A sample), `population` (The whole group). Default: `sample`.

**Outputs**: How far the numbers typically are from their average, or blank when there are too few numbers (a sample needs two).

**Example output**

```json
2.1380899353
```

### Format number

Turn a number into a polished display string with thousands separators, decimal places, and an optional currency symbol or percent sign, for example 1234.5 becomes $1,234.50 and 0.125 becomes 12.50%.

**Inputs**

- Number (`value`, number, required): The number to format.
- Style (`style`, text, required): How the number is presented: plain, grouped with thousands separators, a currency, or a percentage (0.125 is 12.50%). One of: `plain` (Plain (1234.5)), `thousands` (Thousands separators (1,234.5)), `usd` (US Dollars ($)), `eur` (Euros (€)), `gbp` (British Pounds (£)), `jpy` (Japanese Yen (¥)), `currency` (Another currency), `percent` (Percent (12.5%)). Default: `plain`.
- Currency (`currency`, text): The currency's three-letter code, like CAD, AUD, CHF or INR. Well-known currencies get their symbol (CA$, ₹); others are written with their code (CHF 1,234.50). Only when Style is Another currency.
- Decimal places (`decimals`, number): How many decimal places to show. Leave blank for the usual places: 2, or 0 for currencies like yen.
- Separators (`separators`, text): How thousands and decimals are written. With a decimal comma, a currency symbol follows the amount (1.234,56 €). One of: `comma_period` (1,234.56), `period_comma` (1.234,56), `space_comma` (1 234,56), `apostrophe_period` (1'234.56). Default: `comma_period`.

**Outputs**: The number as text, with thousands separators, the chosen decimal places, and a currency symbol or percent sign for those styles.

**Example output**

```json
"$1,234.50"
```

### Round number

Round a number up, down, or to the nearest value.

**Inputs**

- Number (`value`, number, required): The number to round.
- Direction (`mode`, text, required): How to round: to the nearest value (halves away from zero, so 2.5 is 3 and -2.5 is -3), up, or down. One of: `nearest`, `up`, `down`. Default: `nearest`.
- Decimal places (`decimals`, number): How many decimal places to keep. Defaults to 0 (no decimals). Default: `0`.

**Outputs**: The number rounded up, down, or to the nearest value at the chosen decimal places: a whole number when there are none.

**Example output**

```json
3.14
```
