Python/ref math trunc
来自菜鸟教程
<languages />
Python math.trunc()方法
例
查找不同数字的整数部分:
# Import math Library
import math
# Return the truncated integer
parts of
different numbers
print(math.trunc(2.77))
print(math.trunc(8.32))
print(math.trunc(-99.29))
定义和用法
The
math.trunc()
方法返回数字的截断的整数部分。
注意: 此方法不会将数字向上/向下舍入到最接近的整数,而只是删除小数。
句法
math.tanh(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。您要删除的小数部分的数字。如果该值不是数字,则返回TypeError |
技术细节
| 返回值: | An
|
| Python版本: | 1.4 |