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

# Trunc

# \$trunc

The `$trunc` operator truncates the first number to the specified number of decimal places (rounds towards zero).

## Input

* An array containing exactly two numeric values: the number to truncate and the number of decimal places

## Output

* The first value truncated to the specified number of decimal places

## Examples

### Truncate to Integer

```json theme={null}
{
  "$trunc": [
    3.7,
    0
  ]
}
```

Result: `3`

### Truncate to One Decimal Place

```json theme={null}
{
  "$trunc": [
    3.14159,
    2
  ]
}
```

Result: `3.14`

### Truncate Negative Number

```json theme={null}
{
  "$trunc": [
    -3.7,
    0
  ]
}
```

Result: `-3`

### Field Value

```json theme={null}
{
  "$trunc": [
    {
      "$input": "value"
    },
    1
  ]
}
```

Result: The value field truncated to 1 decimal place
