The modulo operator on this calculator gives the result that is different to the most used calculators.
This problem appears when you start using negative numbers.
For example in the Bing and Google calculator, Maxima, Wolfram Alpha and Microsoft Excel the modulo operator gives the next results:
-25 mod 4 = 3
-25 mod -4 = -1
25 mod -4 = -3
on the Windows calculator the results came in like this:
-25 mod 4 = -1
-25 mod -4 = -1
25 mod -4 = 1
As you can see the calculation is performed different. Is it wrong? Well, that's is difficult to answer. But given this article in the Wikipedia, a lot of the programming languages take que second approach, meanwhile the math applications use the first approach.
Given that the calculator is mainly used to do math and not programming (although it has a programmer mode) I suggest that this change is needed and make it behave like a calculator.
I also sent in the past some feedback to the feedback-hub, but I did not put a lot of information.
Expected behavior
We should align scientific and programmatic applications of mod in their respective modes.
Note: A team member edited this comment for clarity on expected behavior
This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.
Thanks for the detailed analysis. I definitely learned something new today about mod. I think I lean toward agreeing with you here:
Is it wrong? Well, that's is difficult to answer. But given this article in the Wikipedia, a lot of the programming languages take que second approach, meanwhile the math applications use the first approach. Given that the calculator is mainly used to do math and not programming... I suggest that this change is needed and make it behave like a calculator.
Since we also offer mod in programmer calculator, would you expect that to follow the programming language convention instead? Do you think it might be confusing to a typical user that they return different results?
Since we also offer
modin programmer calculator, would you expect that to follow the programming language convention instead? Do you think it might be confusing to a typical user that they return different results?
I think it's reasonable for programmer mode to follow programming conventions. Not only does it provide value to the target user of programmer mode but things like division already behave differently in this mode than e.g. standard or scientific.
I would generally agree that we should align with math applications for scientific mode operations and programming languages for programmer mode operations. As pointed out, division already behaves differently.
I don't know how other calculators that have programming mode behave. I think that the programmer mode should stay as it is, although maybe change the name from Mod to Rem (remainder)?
Even better would be to have both options given that the decimal point button is disabled (i did not find any combination of , but that would require som button rearrangement since it would be preferable to have both operators close.
division already behave differently in this mode than e.g. standard or scientific.
Does it? Do you speak about operator precedence ? Or do you mean between Standard/Scientific (float mode) versus Programmer (int mode)?
Does it? Do you speak about operator precedence ? Or do you mean between Standard/Scientific (float mode) versus Programmer (int mode)?
Apologies - mistyped. You're correct, I meant Std/Sci versus Programmer.
@joshkoon: don't worry! It's better to fully understand CalcEngine before trying to modify it, I was afraid to miss something! I took your feedback into account and use remainder in Programmer mode and arithmetic modulo in Normal/Scientific mode, it makes a lot of sense to do it
I would generally agree that we should align with math applications for scientific mode operations and programming languages for programmer mode operations. As pointed out, division already behaves differently.
Good point. Approved and modified comment above to clarify expected behavior.
Most helpful comment
I don't know how other calculators that have programming mode behave. I think that the programmer mode should stay as it is, although maybe change the name from Mod to Rem (remainder)?
Even better would be to have both options given that the decimal point button is disabled (i did not find any combination of , but that would require som button rearrangement since it would be preferable to have both operators close.