Modular Arithmetic With Negative Integers

Ghostgirl

New member
Joined
Sep 18, 2008
Messages
6
Not sure where to post this, sorry if its the wrong place.

I am looking at some notes I made about the mod function:
-14 mod 72 = 58

Can someone explain how negatives work with the mod function? I know how to use it for positives, for example with 34 mod 5, 34/5 = 6.8, 6 X 5 = 30, and 34-34=4 so 34 mod 5 = 4... but I do not understand how 58 could be the answer for -14 mod 72.

Thanks,
GG
 
From what I can tell there is no standard way computers go about implementing the mod function, but here is what I got:

-14 mod 72: -14/72= -0.19, I reversed floored the -0.19 to -1, then computed -1 X 72 = -72, and -14 - (-72) = 58, I'm not sure if this is the right way of going about it or not but I seem to get the right answer. I thought maybe adding the first negative with the modded number (-14 + 72 in this example) might be a short cut, but another example I found which is -115 mod 72 = 29 does not follow this pattern so I guess I am back to square one. By the way, I do not have a book and I am not enrolled in a class, I'm just trying to learn this for my own benefit.
 
Top