且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

匹配函数与公式中的数字不匹配

更新时间:2023-02-21 23:03:13

计算机以2为底进行操作,而不是以10为底进行操作,因此,在执行浮点算术时,即使看起来很正常,也存在一些无法表示的数字.以10为基数.您看到的是0.01,但是Excel实际上已经计算出0.0100000000000000000000x或类似的值.

Computers operate in base 2, not base 10, so when doing floating point arithmetic, there are some numbers that can not be represented, even if they seem perfectly fine in base 10. You are seeing 0.01, but Excel has actually calculated 0.0100000000000000000000x or something along those lines.

如果您想使示例生效,请尝试将B1设置为

If you want to make your example work, try setting B1 to

=ROUND(1-A1,2)

或者,如果您知道只需要两位数字的十进制精度(假设您匹配到0.01),则可以通过以下方式一起避免所有浮点数:

Alternatively, if you know you just need two digits of decimal precision (assumed since you are matching to 0.01), you can just avoid the floating point all together by:

=(100-(100*A1))/100