ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mod function (https://www.excelbanter.com/excel-programming/387738-mod-function.html)

Carl

Mod function
 
The VBA "x Mod y" function and the Excel function =Mod(x,y) produce
consistent results when both parameters are positive. When the number, x, is
negative, these two functions produce different results.
For example the VBA function returns
- 1 = -1 Mod 3
and
the Excel function returns
2 = Mod(-1, 3)

I agree with the Excel function's results.

Anyone have any idea why these functions would have different results?

Mike

Mod function
 
You decide which explanation is best:-

http://mathforum.org/library/drmath/view/52343.html
http://support.microsoft.com/kb/141178

Mike

"Carl" wrote:

The VBA "x Mod y" function and the Excel function =Mod(x,y) produce
consistent results when both parameters are positive. When the number, x, is
negative, these two functions produce different results.
For example the VBA function returns
- 1 = -1 Mod 3
and
the Excel function returns
2 = Mod(-1, 3)

I agree with the Excel function's results.

Anyone have any idea why these functions would have different results?



All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com