问题描述
99.99 * 0.01 = 0.99
很显然这是一个古老的浮点舍入问题,但是在这种情况下舍入误差对我来说似乎相当大;我的意思是我可能预期0.99990000001或类似的关闭结果的结果。
为了记录,我得到了同样的答案在一个JavaVM和一个.Net环境。
为什么0.9998999999999999不够贴近你(和0.9999000000000001是好的)?
abs(0.9999 - 0.9998999999999999)== abs(0.9999 - 0.9999000000000001)
Whereas 99.99 * 0.01 = 0.99
Clearly this is the age old floating point rounding issue, however the rounding error in this case seems quite large to me; what I mean is I might have expected a result of 0.99990000001 or some similar 'close' result.
And for the record I got the same answer in a JavaVM and in a .Net environment.
Why 0.9998999999999999 is not close enough for you (and 0.9999000000000001 is good )?
abs(0.9999 - 0.9998999999999999) == abs (0.9999 - 0.9999000000000001)
这篇关于为什么99.99 / 100 = 0.9998999999999999的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!