TRUNC

Rounds a number (toward zero) to a specified number of decimals

Usage

TRUNC(number, [num_digits])

Parameters

number

(Required) The number to round

num_digits

If zero or positive, the number of decimals to keep. If negative, the number digit to the left of the decimal point to turn to 0. Default is 0 which removes all decimals.

Examples

Example With these variables Result

TRUNC(10)

(None)

10

TRUNC(11.9)

(None)

11

TRUNC(age)

age is 21.8

21

TRUNC(number)

number is -2.9

-2

TRUNC(3.14159265, 3)

(None)

3.141

TRUNC(-1299, -2)

(None)

-1200

More information

You can view this function as removing the part after the decimal point (when num_digit is 0).

This is the same function as ROUNDDOWN, ROUNDDOWN is probably easier to recognize, so is the recommended one.

Reminders

A text containing digits is not handled as a number. To have an actual number:

  • use the @NUMBER_QUESTION to set the variable
  • write a numeric value directly in the code without quotes, ex: age >= 18
  • use a function which converts to a number: NUMBER(text_containing_numbers)
  • use a function which returns a number: FIND("world", "hello everybody")

See also