TRUNC

The function TRUNC takes a a Number and truncates it to a specified number of decimal places.

This function takes two Numbers as input: the first designates the number to be truncated, and the second specifies how many decimal places will remain after truncation. It outputs a single Number: the first number, with all decimal places past the given point removed without rounding.

Declaration

TRUNC(base_number, digits) -> trunc_number

Parameters

base_number (type: Number) The number to be truncated.

digits (type: Number) The number of decimal places that will remain after truncation.

Return Values

trunc_number (type: Number) The base number, truncated to the specified number of decimal places.

Examples

The following example takes the number 1.1234567890 and truncates it so that everything past the eight decimal place is dropped. Note that truncation is not the same as rounding:

TRUNC(1.1234567890, 8) -> 1.12345678

The following example takes the number 1.12 and attempts to truncate it so that everything past the eight decimal place is dropped. 1.12 did not have that level of precision to begin with, and so TRUNC outputs the base number unmodified:

TRUNC(1.12, 8) -> 1.12

Last updated