开发者

Why does the modulo function in excel return the divisor?

开发者 https://www.devze.com 2023-02-18 15:30 出处:网络
I have an Excel validation f开发者_JAVA百科ormula which worked fine in Office \'03, \'07, but is failing in 2010.Did they change the definition of MOD recently?

I have an Excel validation f开发者_JAVA百科ormula which worked fine in Office '03, '07, but is failing in 2010. Did they change the definition of MOD recently?

In 03/07 the following returns zero:

=MOD(1, .05)

However in 2010 it returns .05.

As far as I can tell they haven't changed how remainders worked since I was in 3rd grade when I learned about them. However, Microsoft may be taking certain liberties.


Actually... it does not return zero in Office 2007, but -0.000000000000000056 (just tested).

Maybe it's a floating point issue or the way Excel 2010 handles floating point changed.


So I finally decided the best way to determine this was to cheat and do:

=(1/.05)-(floor(1/.05))

That gives me the zero I need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号