Skip to content

@serenity-is/corelib / trunc

Function: trunc()

trunc(n): number

Defined in: src/base/formatting.ts:319

Truncates a number toward zero to an integer.

Parameters

n

number

Value to truncate; null / undefined returns null.

Returns

number

The integer part of n (toward zero), or null for nullish input.

Example

trunc(1.9);  // 1
trunc(-1.9); // -1