# Round or limit numbers

Shape / columns

A variant of [Apply a maths function](https://meridian.online/operations/apply-a-maths-function).

Round to decimal places or significant figures, round up or down, or clip values to a lower and upper bound.

Page: <https://meridian.online/operations/apply-a-maths-function/round-or-limit-numbers>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

round to places and significant figures, round up and down, and clip to bounds

```sql
CREATE TEMP TABLE nums AS SELECT * FROM (VALUES
  (1, 1234.5678::DOUBLE), (2, 0.00123456::DOUBLE), (3, 0.0::DOUBLE), (4, -15.26::DOUBLE), (5, 2.5::DOUBLE), (6, NULL::DOUBLE)
) t(id, x);
-- round() takes its places as a constant, so significant figures are written with the g format; clipping is a CASE because
-- greatest() and least() skip a NULL and would turn a missing number into a bound
CREATE TEMP TABLE result AS
SELECT id, round(x, 2) AS places, round(x, -2) AS hundreds, round(x) AS whole, format('{:.3g}', x)::DOUBLE AS three_sig,
       ceil(x) AS up, floor(x) AS down, CASE WHEN x < 0 THEN 0.0 WHEN x > 100 THEN 100.0 ELSE x END AS clipped
FROM nums;
SELECT * FROM result ORDER BY id;
SELECT CASE WHEN ((SELECT [places, hundreds, whole, three_sig, up, down, clipped] FROM result WHERE id = 1) = [1234.57, 1200.0, 1235.0, 1230.0, 1235.0, 1234.0, 100.0] AND (SELECT [places, three_sig, clipped] FROM result WHERE id = 2) = [0.0, 0.00123, 0.00123456] AND (SELECT [three_sig, clipped] FROM result WHERE id = 3) = [0.0, 0.0] AND (SELECT [places, whole, three_sig, up, down, clipped] FROM result WHERE id = 4) = [-15.26, -15.0, -15.3, -15.0, -16.0, 0.0] AND (SELECT [whole, up, down, clipped] FROM result WHERE id = 5) = [3.0, 3.0, 2.0, 2.5] AND (SELECT count(*) FROM result WHERE id = 6 AND places IS NULL AND three_sig IS NULL AND clipped IS NULL) = 1) THEN 'as expected' ELSE error('the numbers were not rounded to places and three significant figures, rounded up and down, and clipped between 0 and 100') END AS verdict;
```

The statement builds its own data.

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Duckle: [`Clamp`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Round`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Ibis: [`Ceil`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Clip`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Floor`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Round`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- KNIME Analytics Platform: [`Number Rounder`](https://api.hub.knime.com/nodes/*pUuELUhDh08r8wjt?details=full) (read 2026-09-27)
- Polars: [`Expr manipulation/selection: rounding and bounds (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
