TRUNC function

TRUNC(Number, DigitCount?) TRUNC(Number; DigitCount?)

Number

Number or { Number }

The number to truncate.

DigitCount

Number or { Number } (optional)

The number of decimal places the resulting number should have, if the number is positive. If the number is negative, the number is modified to the left of the decimal separator. If omitted, it is assumed to be 0, meaning that this function returns an integer.

Returns

Number or { Number }

A truncated number.

Returns a number truncated to a certain precision. TRUNC(22.1)TRUNC(22,1) returns 22. TRUNC(-22.1)TRUNC(-22,1) returns -22. Unlike INT, TRUNC never rounds numbers, it just cuts off decimals.

If the number of digits is not specified, 0 is assumed, which means that this function returns integers (whole numbers).

If the number if digits is positive, the parameter is interpreted as the number of decimal places the number should have. TRUNC(1.49, 1)TRUNC(1,49; 1) returns 1.4 (one decimal place) and TRUNC(PI(), 5)TRUNC(PI(); 5) returns 3.14159 (five decimal places).

If the number of digits is negative, the number is modified to the left of the decimal separator. TRUNC(123456789, -3)TRUNC(123456789; -3) returns 123456000 and TRUNC(123456789, -6)TRUNC(123456789; -6) returns 123000000.

Examples

TRUNC(22.1)TRUNC(22,1)

Returns 22.

TRUNC(-22.1)TRUNC(-22,1)

Returns -22.

TRUNC({ 22.1, -22.1 })TRUNC({ 22,1; -22,1 })

Returns the array { 22, -22 }{ 22; -22 }.