I am having a problem with the java modulus function.
for some reason the computer has -3 % 26 equal to -3 when it should equal 23 since the lowest multiple of 26 less than -3 is -26 and -3 - -26 is 23. Also, if you add 26 to -3 which is essentially adding a modulus of 0, so the result should not change, and the result becomes 23. Can anyone explain why java has -3 % 26 == -3 and not 23 and how to fix this problem?
Aucun commentaire:
Enregistrer un commentaire