mindspore.numpy.trunc
- mindspore.numpy.trunc(x, dtype=None)[源代码]
- 逐元素返回输入的截断值。 - 标量 x 的截断值是距离 x 最近且趋近0的整数 i,即 x 的小数部分被舍弃。 - 说明 - 不支持NumPy参数 out 、 where 、 casting 、 order 、 subok 、 signature 、 extobj 。 - 参数:
- x (Tensor) - 输入数据。 
- dtype (mindspore.dtype, 可选) - 默认值: - None。 覆盖输出Tensor的dtype。
 
- 返回:
- Tensor或标量, x 中每个元素的截断值。 如果 x 是标量,则返回标量。 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> import mindspore.numpy as np >>> output = np.trunc(np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])) >>> print(output) [-1. -1. -0. 0. 1. 1. 2.]