Number.RoundTowardZero
NumberTruncates a number toward zero to the specified number of decimal places, always rounding toward zero regardless of the fractional part.
Syntax
Number.RoundTowardZero(number as nullable number, optional digits as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
number | number | Yes | The number to truncate. |
digits | number | No | The number of decimal places to keep. Defaults to 0 (truncate to integer). |
Return Value
number — The number truncated toward zero to the specified decimal places.
Remarks
Number.RoundTowardZero truncates the fractional part of a number, always moving the result toward zero (never away from zero). For positive numbers, this is equivalent to Number.RoundDown (floor). For negative numbers, it is equivalent to Number.RoundUp (ceiling) — -3.9 truncates to -3, not -4.
This contrasts with Number.RoundDown, which always rounds toward negative infinity: Number.RoundDown(-3.9) = -4, while Number.RoundTowardZero(-3.9) = -3.
No tie-breaking rule applies — the fractional portion is simply discarded regardless of its magnitude (so 3.1 and 3.9 both become 3). This makes Number.RoundTowardZero useful for:
- Strict truncation: retaining only complete units (e.g., full days, full units) without ever inflating values
- Integer part extraction: equivalent to Number.IntegerDivide(x, 1) for unit truncation
- Decade/bucket bucketing: Number.RoundTowardZero(age / 10) * 10 gives the decade bracket
The optional digits parameter specifies how many decimal places to preserve after truncation.
Examples
Example 2: Truncate a negative number toward zero (not toward -∞)
Number.RoundTowardZero(-3.9)Result | |
|---|---|
| 1 | -3 |
Example 4: Bucket salary into decade bracket for each employee
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Employees, 3), {"FullName", "Salary"}),
"SalaryBracket",
each Number.RoundTowardZero([Salary] / 10000) * 10000,
type number
)FullName | Salary | SalaryBracket | |
|---|---|---|---|
| 1 | alice smith | 55,000 | 50,000 |
| 2 | BOB JONES | 95,000 | 90,000 |
| 3 | Charlie Brown | 72,000 | 70,000 |