我们都做过一些基本的数学运算,我们曾经用很多十进制数字来缩短一个数字。如果Truncate和Round of 听起来很熟悉,那么你做对了。在这篇文章中,我们将展示如何在Microsoft Excel中使用(Microsoft Excel)TRUNC函数。
在继续之前,让我们先了解一下Trunc和Round之间的根本区别。如果您有一个十进制数 5.678,那么使用Trunc将得到 5.67。与此Round函数相比,结果为 5.68。注意到(Notice)区别了吗?Round函数将选择下一个最大的数字,而Trunc将(Trunc)完全相反。
TRUNC 函数
Trunc 函数与Excel 中的任何其他函数或公式(any other function or formula in Excel)一样,它采用参数(parameters)。其中一个参数是需要截断的数字,而第二个参数是(number)小数位数。 (number of decimal places. )简而言之,TRUNC函数将数字截断为指定的小数位数。
Trunc 函数的语法: (The syntax for Trunc function: )
TRUNC(number, [num_digits])
Digits,第二个参数可选,默认值为0。表示如果不传或不指定值,会去掉所有的数字,将数字减到最接近的小数。
请记住(Remember),在负数的情况下结果将相反。
如何在 Excel 中使用 TRUNC 函数
了解如何在Excel中使用(Excel)TRUNC函数的最佳方式是通过示例。关于应用它,它有点简单。
- 在Excel文件中,选择您希望截断数字出现的位置。
- 双击(Double)要编辑的单元格,值,然后键入= Trunc (C4, 2)。C4是excel上的一个单元格,带有一个数字。
- 键入Trunc 后(Trunc),您将能够选择 Excel 上的任何单元格。关闭括号,然后按Enter键
- 如果没有错误,您应该会看到截断的值。
数字很重要
使用Trunc(Trunc)函数时,不能将相同的数字参数应用于所有小数。如果有一个小数点后只有一位的数字,而您使用数字 3 作为数字参数,则不会影响。在上面的例子中,51.4 保持不变,因为我们选择了更高的数字参数,而小数点后只有一位。同样,即使增加数字的值,也不会显示更多。
相关:(Related:) Office Excel 提示和技巧(Office Excel Tips and Tricks)
哪里可以使用截断功能(Trunc Function)?
有几个地方可以使用此功能。
- DateTime Stamp:当您在单元格中同时拥有日期和时间时,您可以使用Trunc删除时间并提取数据。
- 删除小数(Decimal):如果你只想要整数而不是小数,Trunc without Digits参数。
- 将负数作为数字参数传递将截断小数点前的数字。28.99 将截断为 20。
- 这也意味着您可以将整数截断为最低形式。二十九将截断为二十。
与学校数学不同,Roundoff不执行这两个功能。Round函数的作用与Trunc正好(Trunc)相反。
阅读下一篇(Read next):如何使用 Excel 设计简单的平面图(How to use Excel to design simple Floor Plans)。
How to use the TRUNC function in Microsoft Excel with Examples
We all have done some baѕic maths where wе used to shorten a numbеr with a lot of decimal digit. If Truncate and Round of sounds familiar, then you got it right. In this post, we will show how you can use the TRUNC function in Microsoft Excel.
Before we go ahead, let’s brush on the fundamental difference between Trunc and Round. If you have a decimal number of 5.678, then using Trunc will result in 5.67. Compared to this Round function will result in 5.68. Notice the difference? The Round function will choose the next highest number, while Trunc will do the exact opposite.
The TRUNC Function
The Trunc function like any other function or formula in Excel, which takes parameters. One of the parameters is the number which needs to be truncated, while the second is to the number of decimal places. In simple words, the TRUNC function truncates a number to a specified number of decimal places.
The syntax for Trunc function:
TRUNC(number, [num_digits])
Digits, the second parameter is optional, and the default value is 0. It means if you do not pass or specify a value, it will remove all digits, and reduce the number to the closest lower number.
Remember, the result will be the opposite in the case of negative numbers.
How to use TRUNC function in Excel
The best way to understand how you can use the TRUNC function in Excel is by example. About applying it, it is tad simple.
- In the Excel file, choose where you want the truncated number to appear.
- Double click on the cell to edit, the value, and then type = Trunc(C4, 2). C4 is a cell on excel which carries a numerical.
- As soon as you type Trunc, you will be able to choose any cell on the excel. Close the bracket, and hit the Enter key
- If there are no errors, you should see the truncated value.
Digits matter
You cannot apply the same digits parameter to all decimals when using the Trunc function. If there is a number that has only one digit place after the decimal, and you use number 3 as a digit parameter, then it will not affect. In the above example, 51.4 remains the same as we chose a higher digit parameter while there is only one digit after the decimal. Similarly, even if you increase the value of the digit, it will not show more.
Related: Office Excel Tips and Tricks
Where can you use the Trunc Function?
There are a couple of places you can use this function.
- DateTime Stamp: When you have both dates, and time in a cell, you can use Trunc to remove time and extract the data.
- Removing Decimal: If you just want whole numbers and not the decimal, Trunc without Digits parameter.
- Passing a negative number as the digits parameter will truncate the number before the decimal. 28.99 will truncate to 20.
- It also means you can Trunc whole numbers to their lowest form. Twenty-nine will truncate to twenty.
Unlike school maths, Roundoff doesn’t perform both functions. The Round function does precisely the opposite of the Trunc.
Read next: How to use Excel to design simple Floor Plans.