Modulo operation is something we all aware of from long time and this , infact brings out an interesting perspective on how Microsoft and Google has implemented it. Try out finding the result for following operation in C# or VB or even Windows Calculator.

"-5 mod 6"

Your result was -5 right ??? Now attempt the same in Google Calculator ?? -1 the result ??

Which is correct ? Its going to be an interesting argument. The Modulo function is definaed as the amount by which a number exceeds the largest integer multiple of the divisor that is not greater than that number.

Now if you go by that defination , - 5 * -1 would yield 5 with a remaining -1. That would explain the answer given by Google. But Microsoft's answer too can be argued.

The normal formula to calculate Mod is given by r = a - n(a/n). Now assuming Microsoft calculates this using r = a - n * abs(a/n) , then answer given by Calculator is correct.

Counter argument exists in both cases and hence it is argueable on sides of both parties about which is the correct solution.

Manoj ++, A Global Citizen in its making…!

11 months ago