Solved

What does modulo mean?

Posted on 2011-09-08
12
636 Views
Last Modified: 2012-05-12
In my Data Structures textbook it says:

"We say that A is congruent to B modulo N, written A = B (mod N), if N divides A - B. Intuitively this means that the remainder is the same when either A or B is divided by N. Thus, 81 = 61 = 1 (mod 10)"

Does modulo mean that division using the number N yields the same remainder on both A and B?
0
Comment
Question by:shampouya
  • 5
  • 3
  • 2
  • +1
12 Comments
 

Author Comment

by:shampouya
Comment Utility
The equals signs above should have three lines, not two. I couldn't get the congruency symbol to work in this browser.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
yes
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
provided that the sign of the remainder does not depend on the sign of A or B, so that
-9 = 81 = 61 = 1 (mod 10)
0
 

Author Comment

by:shampouya
Comment Utility
Can you explain the -9 part in your post? I didn't understand that part.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
10 divides 1 - -9
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
But some division operators are defined so that the remainder is the same sign as the dividend.
the "remainder is the same" intuition works better with division operators that are defined so that the remainder is the same sign as the divisor
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Closing Comment

by:shampouya
Comment Utility
thanks
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility


@ozo: if I understand correctly, provided that the sign of the remainder does not depend on the sign of A or B -9 mod 10 = 9, but -11 mod 10 = 1?
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
No paul, it's a straight pattern
5 mod 3 = 2
4 mod 3 = 1
3 mod 3 = 0
2 mod 3 = 2
1 mod 3 = 1
0 mod 3 = 0
-1 mod 3 = 2
-2 mod 3 = 1
-3 mod 3 = 0
-4 mod 3 = 2

So the negatives are sort of backwards to the positives.
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
In some places it goes like this:
5 mod 3 = 2
4 mod 3 = 1
3 mod 3 = 0
2 mod 3 = 2
1 mod 3 = 1
0 mod 3 = 0
-1 mod 3 = -1
-2 mod 3 = -2
-3 mod 3 = 0
-4 mod 3 = -1

But if you add the divisor to the mod, it gives the same answer as before.

0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
I actually learned that at university in my IT courses back in the late 70's! My RAM is gettint a little screwed up! Too mush stuff in there!
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
5 mod 3 = 2
4 mod 3 = 1
3 mod 3 = 0
2 mod 3 = 2
1 mod 3 = 1
0 mod 3 = 0
-1 mod 3 = 2
-2 mod 3 = 1
-3 mod 3 = 0
-4 mod 3 = 2
So the negatives are sort of backwards to the positives.

I'd say that the negatives follow exactly the same pattern as the positives
Whereas
In some places it goes like this:
5 mod 3 = 2
4 mod 3 = 1
3 mod 3 = 0
2 mod 3 = 2
1 mod 3 = 1
0 mod 3 = 0
-1 mod 3 = -1
-2 mod 3 = -2
-3 mod 3 = 0
-4 mod 3 = -1
seems to be "backwards"

To me it makes no sense to have 5 different mod 3 classes

a mod b can be defined as
a - b*floor(a/b)
which works consistently for any sign of a or b, and even for non-integer a or b

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now