mindspore.numpy.rint

mindspore.numpy.rint(x, dtype=None)[源代码]

Rounds elements of the array to the nearest integer.

说明

Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. Ascend does not support dtype float64 currently.

参数
返回

Output tensor is same shape and type as x. This is a scalar if x is a scalar.

异常

TypeError – If x can not be converted to tensor.

Supported Platforms:

Ascend GPU CPU

样例

>>> import mindspore.numpy as np
>>> x = np.array([-1.7, -1.5, 0.2, 1.5, 1.7, 2.0])
>>> print(np.rint(x))
[-2. -2. 0. 2. 2. 2.]