> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lionlang.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# number module: arithmetic and comparisons

> Lion's number module provides add, subtract, multiply, divide, and five comparison functions for working with numeric values in JSON expressions.

The `number` module covers all basic arithmetic and comparison operations for numeric values in Lion. Every function validates its arguments through Effect schemas, so passing a non-number produces a typed error rather than a runtime surprise. All nine functions take exactly two arguments.

## Arithmetic

### `number/add`

Returns the sum of two numbers.

```json theme={null}
["number/add", 1, 2]
```

Result: `3`

***

### `number/subtract`

Subtracts the second number from the first.

```json theme={null}
["number/subtract", 10, 3]
```

Result: `7`

***

### `number/multiply`

Returns the product of two numbers.

```json theme={null}
["number/multiply", 5, 4]
```

Result: `20`

***

### `number/divide`

Divides the first number by the second.

```json theme={null}
["number/divide", 20, 4]
```

Result: `5`

<Note>
  Division by zero follows JavaScript semantics and returns `Infinity` rather than throwing. Validate your divisor with `number/equals?` if you need to guard against it.
</Note>

## Comparisons

All comparison functions return a boolean.

### `number/equals?`

Returns `true` when both numbers are strictly equal.

```json theme={null}
["number/equals?", 5, 5]
```

Result: `true`

***

### `number/lessThan`

Returns `true` when the first number is less than the second.

```json theme={null}
["number/lessThan", 3, 5]
```

Result: `true`

***

### `number/greaterThan`

Returns `true` when the first number is greater than the second.

```json theme={null}
["number/greaterThan", 5, 3]
```

Result: `true`

***

### `number/lessThanOrEqualTo`

Returns `true` when the first number is less than or equal to the second.

```json theme={null}
["number/lessThanOrEqualTo", 3, 5]
```

Result: `true`

***

### `number/greaterThanOrEqualTo`

Returns `true` when the first number is greater than or equal to the second.

```json theme={null}
["number/greaterThanOrEqualTo", 5, 5]
```

Result: `true`

## Using comparisons with `cond`

Comparison functions are the natural fit for `cond` branches:

```json theme={null}
["cond",
  [["number/greaterThan", "score", 90], "great"],
  [["number/greaterThan", "score", 70], "pass"],
  ["else", "retry"]]
```

<Tip>
  Bind frequently used values with `define` before computing with them. For example, store a tax rate once and reference it by name in multiply expressions.
</Tip>
