为什么 numpy.round 给出错误的输出?

问题描述 投票:0回答:1

从什么时候8.5四舍五入到8.0?我想也许只是舍入 0.5,但 7.5 也舍入到 8.0? numpy 坏了还是我错过了什么......

我尝试了几个数字,它也被破坏为 0.5,给出 0.0 而不是 1.0。知道发生了什么事吗?

python numpy rounding
1个回答
0
投票

来自:

import numpy as np
help(np.round)
   ...
   Notes
    -----
    For values exactly halfway between rounded decimal values, NumPy
    rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
    -0.5 and 0.5 round to 0.0, etc.
   ...
© www.soinside.com 2019 - 2024. All rights reserved.