說明
Use this function to truncate a number to a specified number of digits. Supported in Chains.
TRUNC removes the fractional part of a number without rounding. It's useful for removing decimal places or extracting the integer part of a number.
Note: TRUNC differs from the ROUND function, in that TRUNC always truncates towards zero, while ROUND rounds up or down based on the digit to the right of the specified decimal place.
語法
TRUNC(number, [num_digits])
Inputs
This function accepts the following arguments:
名稱 | 必要 | 說明 | Valid input |
---|---|---|---|
數字 |
是 | The number you want to truncate. | A real number, a reference to a cell containing a real number, or a formula which results in either of these. |
num_digits |
沒有 | The number of digits to which you want to truncate the number. | An integer, a reference to a cell containing an integer, or a formula which results in either of these. If omitted, it's treated as 0. |
範例
Sample Data
A | B |
---|---|
數量 | 說明 |
3.14159 | Pi |
-2.718 | Negative e |
1234.5678 | Large number |
0.00123 | Small number |
Sample formulas
公式 | 說明 | 結果 |
---|---|---|
=TRUNC(A2) |
Truncates Pi to an integer. | 3 |
=TRUNC(A2, 2) |
Truncates Pi to 2 decimal places. | 3.14 |
=TRUNC(A3) |
Truncates negative e to an integer. | -2 |
=TRUNC(A4, -2) |
Truncates the large number to hundreds. | 1200 |
=TRUNC(A5, 4) |
Truncates the small number to 4 decimal places. | 0.0012 |
附註
- TRUNC always truncates towards zero, regardless of whether the number is positive or negative.
- If num_digits is greater than 0, TRUNC truncates to the specified number of decimal places.
- If num_digits is 0 or omitted, TRUNC truncates to an integer.
- If num_digits is negative, TRUNC truncates digits to the left of the decimal point.
- TRUNC does not round numbers; it simply removes the specified digits.
提示
- Use TRUNC when you need to remove decimal places without rounding.
- TRUNC can be useful in financial calculations where you want to discard fractional cents.
- Combine TRUNC with other functions like INT or MOD for more complex number manipulations.
- Be aware of the difference between TRUNC and ROUND to choose the appropriate function for your needs.
- Consider using the other rounding functions (linked in Related functions) if you need to round numbers in a different manner.