round函数并不是绝对的四舍五入【Python琐碎知识点】

a1 = np.array([1.4,2.5,2.6],dtype='float64')
print(a1.round(0))

a2 = np.array([2.5,2.51,2.501,2.50000001],dtype='float64')
print(a2.round(0))

######### 输出 ################

[1. 2. 3.]
[2. 3. 3. 3.]

具体对比知晓 :
绝对的临界值并没有五入!但只要打破绝对的临界值,增加一点点小数就可以"五入"。

猜你喜欢

转载自blog.csdn.net/m0_38052500/article/details/106853302
今日推荐