Dispositive explanation....
Originally Posted by
joeu2004
I speculated that, in part, the difference might be 64-bit v. 80-bit binary floating-point arithmetic. And that does seem to be sufficient to explain the Excel 2010 result for =MOD(1.5,0.05).
I also speculated that, in part, the difference might be what I call "Excel INT" v. "true Int". That alludes to the fact that Excel INT does not always return the truly truncated integer result.
However, neither speculation explains the infinitesimal result from Excel 2003/2007 =MOD(1.5,0.05).
The subtle differences depend only on if and when subexpressions are converted from 80-bit to 64-bit binary floating-point internally.
For MOD(1.5,.0.05) per se, there is no issue with the implementation of Excel INT v. "true Int". TBD: Whether anomalies of Excel INT affect any examples of Excel MOD.
[ERRATA] Yes, generally they do. See the errata in the xlMod2003 and xlModForumla functions.
Note: The following emulations do not address defects with Excel MOD for certain combinations of parameters, notably KB 119083 (click here) [2].
The implementation of Excel 2003 and 2007 MOD can be emulated by the following:
The implementation of Excel 2010 MOD can be emulated by the following:
[EDIT] 1.5 is represented exactly internally, but 0.05 is approximated by
0.0500000000000000,0277555756156289135105907917022705078125. Note that the approximation is infinitesimally greater than the decimal fraction. So 1.5/0.05 is indeed less than 30 arithmetically.
For completeness....
The implementation of the Excel formula x - y*INT(x/y) can be emulated by the following:
The following implementation does not correspond to any Excel MOD result, AFAIK [1]:
-----
[1] I do not have Excel 2013 and Excel 2016 to test.
[2] http://support.microsoft.com/kb/119083
Bookmarks