Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What does modulo mean?

Posted on 2011-09-08
12
Medium Priority
?
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 

Author Comment

by:shampouya
ID: 36507065
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
ID: 36507072
yes
0
 
LVL 84

Expert Comment

by:ozo
ID: 36507085
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Expert Comment

by:ozo
ID: 36507140
10 divides 1 - -9
0
 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 36507147
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
 

Author Closing Comment

by:shampouya
ID: 36507166
thanks
0
 
LVL 33

Expert Comment

by:Paul Sauvé
ID: 36507239


@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
ID: 36507467
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
ID: 36507480
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 33

Expert Comment

by:Paul Sauvé
ID: 36507509
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
ID: 36508246
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Suggested Courses

596 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