Trunc() Function
Trunc() Function
The Excel TRUNC function returns a truncated number based on a given number of digits. For example, TRUNC(4.9) will return 4, and TRUNC(-3.5) will return -3. The TRUNC function does no rounding, it simply truncates as specified.
Syntax
The syntax for the TRUNC function in Microsoft Excel is:
=TRUNC( number, [digits] )
Parameters or Arguments
number
The number to truncate.
digits
Optional. It is the number of decimal places to display in the resulting truncated number. If this parameter is omitted, the TRUNC function will assume 0.
Trunc Function Examples
The following spreadsheet shows several examples of the Excel Trunc function:
Formulas:
A
|
B
| |
1
|
99.999
|
=TRUNC( A1, 1 )
|
2
|
99.999
|
=TRUNC( A2, 2 )
|
3
|
99.999
|
=TRUNC( A3 )
|
4
|
99.999
|
=TRUNC( A4, -1 )
|
5
|
-99.999
|
=TRUNC( A5, 2 )
|
6
|
-99.999
|
=TRUNC( A6, -1 )
|
Results:
A
|
B
| |
1
|
99.999
|
99.9
|
2
|
99.999
|
99.99
|
3
|
99.999
|
99
|
4
|
99.999
|
90
|
5
|
-99.999
|
-99.99
|
6
|
-99.999
|
-90
|
The example in cell B3 of the above spreadsheet shows that, when the [num_digits] argument is omitted, it takes the default of 0. I.e. the supplied number is truncated to an integer.
Note
Ø A positive [num_digits] value specifies the number of digits to the right of the decimal point.
Ø If [num_digits] is 0 (or is omitted), the supplied number is truncated to the nearest integer.
Ø A negative [num_digits] value specifies the number of digits to the left of the decimal point.
Comments
Post a Comment