TRUNC

The TRUNC function rounds a real number to its integer part or to the real number with the specified decimal places.

Syntax

TRUNC(
    number
    [, num_digits]
)

Parameters
  • number: Number whose integer part is to be obtained.
  • num_digits: Optional argument. Number of decimal places to include in the result.
Returned value

The TRUNC function returns an integer or a real number -if the function is applied to a non-integer and the argument num_digits is greater than or equal to 1-.

Additional Information

If the num_digits argument is not included, it is considered to be 0 by default.

The TRUNC and INT functions return the same result for positive numbers. On the contrary, applied to a negative number return different results: TRUNC returns the integer part (that is, the number stripped of its decimal part) while INT returns the nearest lower integer (that is, the INT function applied to -5.4 returns -6, for example).

Examples

This example applies the TRUNC function to a set of numbers without specifying the value of the num_digits argument (that is, taking the value 0):

TRUNC function. Example of use

If the function is applied to the same set of numbers with the argument num_digits taking the value 1, the results obtained are the following:

TRUNC function. Example of use

The behavior of the different rounding functions is summarized below:

  • ROUNDDOWN: Rounds a number towards zero where the number of decimal places can be specified.
  • ROUNDUP: Rounds a number away from zero where the number of decimal places can be specified.
  • ROUND: Rounds a number towards the nearest rounding value where the number of decimal places can be specified.
  • INT: Rounds a number to the nearest equal or lower integer.
  • TRUNC: Rounds a number towards its integer part where the number of decimal places can be specified.

Examples:

Rounding functions

Related functions
Category
Mathematical and trigonometric
Submitted by admin on Tue, 12/04/2018 - 12:22