Skip to main content
These functions adjust or inspect a number’s value. Each accepts a number or a table, returning the same shape, and a unit on the value is carried through to the result. sign is the exception: it reports a direction, so it returns a bare number.
Round only when you mean to change the value. TrueMath carries values at full precision through every step. round, floor, and ceil permanently discard that precision, and a rounded value used in a later calculation introduces error that compounds across steps. They also change the value an activity returns, which can make it impossible to solve in reverse.To show fewer decimals without losing precision, set the variable’s display format instead of rounding.

Round [round]

Rounds to places following standard rounding (digits 0–4 round down, 5–9 round up). Set places to 110 to round to that decimal place, or 0 to -10 to round to a whole-number place; it defaults to 0. places must be a whole number in the range -10 to 10 (real numbers are truncated); outside that range returns a Parameter out of range error. Given a date and a quoted time unit, round snaps to the nearest boundary of that unit instead — see Snapping a date to a boundary.

Floor [floor]

The largest value less than or equal to value at the given places. places follows the same rules as round. Given a date and a quoted time unit, floor snaps back to the boundary at or before the date — see Snapping a date to a boundary.

Ceiling [ceil]

The smallest value greater than or equal to value at the given places. places follows the same rules as round. Given a date and a quoted time unit, ceil snaps forward to the boundary at or after the date — see Snapping a date to a boundary.

Snapping a date to a boundary

When the first argument is a date, all three functions accept a quoted time unit in place of places, which snaps the date to that unit’s boundary — the start of the day, the first of the month, the nearest hour.
A boundary is the instant a period starts — the year boundaries are January 1 at midnight, the month boundaries are the 1st at midnight, the day boundaries are midnight. Snapping zeros every component finer than the unit named. Six units are accepted, one per calendar component: Those six are the whole set, because each names a calendar component that can be zeroed. "wk" is not among them — a week is not a component of a date — and a unit from another dimension, such as "m" or "lb", returns input.incompatible_units. Because boundaries are period starts, ceil moves forward to the start of the next period, not to the last day of the current one: ceil(d; "yr") on any date in 2026 is January 1, 2027, and ceil(d; "mo") on July 21 is August 1. December 31 is not a year boundary — it is the last day inside the year, which is a different thing. To get the last day of a period, take the next boundary and step back a day with adjdate:
A date already exactly on a boundary is returned unchanged by both floor and ceil, so applied to date(2026; 8; 1) that idiom gives July 31 — the previous period’s last day. Snap or offset first if the input might land on a boundary.
With no second argument at all, floor and ceil still act on the number, and for a date that means the whole second — floor(d) and floor(d; "s") agree. Snapping is also how dates are compared at a coarser granularity than the exact instant. Two dates are equal only when their values match to the second, so snap both sides to the same unit and compare the results:

Absolute value [abs]

The absolute (non-negative) value.

Sign [sign]

-1 if value is negative, 0 if zero, 1 if positive. The result is a bare number even when value carries a unit — it is a direction, not a quantity.

Integer part [ipart]

The integer (whole-number) portion of value.

Fractional part [fpart]

The fractional (decimal) portion of value.