> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Saturating math overview

> Perform saturating math operations on integers

The saturating math hyperfunctions help you perform saturating math on integers. In saturating math, the final result is
bounded. If the result of a normal mathematical operation exceeds either the minimum or maximum bound, the result of the
corresponding saturating math operation is capped at the bound. For example, `2 + (-3) = -1`. But in a saturating math
function with a lower bound of `0`, such as [`saturating_add_pos`][saturating_add_pos], the result is `0`.

You can use saturating math to make sure your results don't overflow the allowed range of integers, or to force a result
to be greater than or equal to zero.

<Note>
  All saturating math functions are in the `toolkit_experimental` schema. You must use schema-qualified names:

  ```sql theme={"dark"}
  SELECT toolkit_experimental.saturating_add(100, 50);
  ```

  Alternatively, add the schema to your search path:

  ```sql theme={"dark"}
  SET search_path TO public, toolkit_experimental;
  ```
</Note>

## Available functions

### Addition

* [`saturating_add()`][saturating_add]: add two numbers, saturating at the 32-bit integer bounds instead of overflowing
* [`saturating_add_pos()`][saturating_add_pos]: add two numbers, saturating at 0 for the minimum bound

### Subtraction

* [`saturating_sub()`][saturating_sub]: subtract one number from another, saturating at the 32-bit integer bounds
  instead of overflowing
* [`saturating_sub_pos()`][saturating_sub_pos]: subtract one number from another, saturating at 0 for the minimum bound

### Multiplication

* [`saturating_mul()`][saturating_mul]: multiply two numbers, saturating at the 32-bit integer bounds instead of
  overflowing

[saturating_add]: /api-reference/timescaledb-toolkit/saturating-math/saturating_add

[saturating_add_pos]: /api-reference/timescaledb-toolkit/saturating-math/saturating_add_pos

[saturating_mul]: /api-reference/timescaledb-toolkit/saturating-math/saturating_mul

[saturating_sub]: /api-reference/timescaledb-toolkit/saturating-math/saturating_sub

[saturating_sub_pos]: /api-reference/timescaledb-toolkit/saturating-math/saturating_sub_pos
