使用python 2.7.17或3.6.9时,使用值“1e11”时会出现奇怪的行为 对于两个版本:
>>> 1.0e-11*1.0e11
0.9999999999999999
>>> 1.0e-10*1.0e10
1.0
>>> 1.0e-12*1.0e12
1.0
>>> 1.0e-13*1.0e13
1.0
etc.
>>> 1.0-(1.0e-11*1.0e11)
1.1102230246251565e-16
同时,对于所有其他指数[编辑:低于20],结果正确为0.0。显然存在一些浮点精度问题,但为什么指数10、11和12之间不一致呢。这是怎么回事
相关问题 更多 >
编程相关推荐