# trunc() Function & Examples

Use the trunc() math function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

Try it yourself:

---

## trunc(): remove a fractional part

**trunc(x)** rounds toward zero. `trunc(3.8)` is 3 and `trunc(-3.8)` is −3.

## Compare rounding rules

Truncation differs from [floor()](https://calcul.io/function/floor/index.md), which sends −3.8 to −4, and [ceil()](https://calcul.io/function/ceil/index.md), which sends it to −3. Use [round()](https://calcul.io/function/round/index.md) for nearest-integer behavior.

## Useful checks

Use [isInteger()](https://calcul.io/function/isInteger/index.md) to see whether truncation changes a value, [abs()](https://calcul.io/function/abs/index.md) for magnitude, and [sign()](https://calcul.io/function/sign/index.md) for direction.

## Caveat

Truncation discards information. Do not use it to validate counts unless rounding toward zero is the intended rule.

[All functions](https://calcul.io/functions/index.md)
