Why is -101 mod 13 = 3 and not 10

  • Context: High School 
  • Thread starter Thread starter Superdemongob
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the calculation of the modulo operation, specifically why -101 mod 13 equals 3 instead of 10. Participants explore the long division method, the properties of remainders, and the conventions of modulo operations with negative numbers.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes their long division process for -101 / 13, noting that they arrive at -10 after the first step and questions whether this is where the calculation should stop.
  • Another participant states that -101 is congruent to -10 mod 13 and explains that -10 can be expressed as 13 times -1 plus 3.
  • A later reply acknowledges understanding the modulo operation and asks if the equivalence of -101 and -10 mod 13 is due to the remainder being the same.
  • Another participant clarifies that the normal convention for modulo is that the result shares the sign of the divisor, which leads to the conclusion that -101 / 13 results in a quotient of -8 and a remainder of +3.
  • One participant discusses how different programming languages handle modulo operations with negative numbers, noting that some may yield results that differ from mathematical conventions.
  • Another participant uses the analogy of a 13-hour clock to illustrate the concept of negative modulo, explaining how moving counterclockwise leads to the same result of 3 after adjusting for the overshoot.

Areas of Agreement / Disagreement

Participants express differing views on the interpretation of modulo with negative numbers and the conventions used in various contexts. There is no consensus on a single approach, as multiple perspectives on the calculation and its implications are presented.

Contextual Notes

Participants mention the importance of the sign of the divisor in determining the result of the modulo operation, as well as the implications of rounding in division. Some assumptions about the behavior of programming languages and mathematical conventions are also noted but remain unresolved.

Superdemongob
Messages
8
Reaction score
0
This is a very basic question that I am having some difficulty grasping.

When I do the long division for -101 / 13, my first step is -7 which comes out to -91 and so I have left -10.

Shouldn't this be where the calculation stops?

One of the thoughts I had was that as -13 is smaller than -10, I should go one step further and subtract -13 from -10 to get +3. and that's why the mod is 3.

If that is correct, could someone please explain why?
If that is incorrect, could someone please explain how we get 3 instead of 10?

Thanks for any help.
 
Physics news on Phys.org
So you have that -101\equiv -10 ~\mbox{mod} ~13

So -10 = 13 (-1) + 3, right ?
 
EDIT: I totally just got it. Thank you so much for your prompt response.

Sorry, i know that I'm being really thick on this and once i see it i'll kick myself but 1 follow up question if you don't mind.

is the reason you know that -101\equiv -10 ~\mbox{mod} ~13 because you know that the remainder will be the same?
 
Last edited:
Superdemongob said:
is the reason you know that -101\equiv -10 ~\mbox{mod} ~13 because you know that the remainder will be the same?
Not sure what you mean by the question, but -101 + 13*7 = -10, so they must be the same mod 13 (and mod 7).
Btw, there are programming languages that get modulo of negative numbers 'wrong' (from a mathematician's perspective). Very annoying.
 
Superdemongob said:
When I do the long division for -101 / 13, my first step is -7 which comes out to -91 and so I have left -10.
The normal convention for modulo is that the sign of the result is the same as the sign of the divisor. This means that the range of modulo 13 is limited to the set of 13 numbers {0, 1, 2, ... , 10, 11, 12}, none of them negative.

To continue with this line of thinking, then -101 / 13: results in a quotient of -8 with a remainder of +3.

Similary, the range of modulo -13 is (-12, -11, -10, ... -2, -1, 0}, so 101 / (-13) results in a quotient of -8 and remainder -3.

So using this model, quotients are always rounded down towards -∞, instead of towards zero. Older computers with signed non-restoring divide algorithm performed division in this manner, but I'm not aware of any current computers that do this. The computer language APL, implements modulo as described above.

One advantage of using this convention is that it's is origin independent, let a, b c, n, and q be integers:

if a mod b = c, then (a ± n b) b mod = c

if a / b = q, then (a ± n b) / b = q ± n

This wouldn't hold true if quotients didnt round down towards -∞, and c was not restricted to have the same sign as b (or be equal to zero).
 
Last edited:
dextercioby said:
So you have that -101\equiv -10 ~\mbox{mod} ~13

So -10 = 13 (-1) + 3, right ?

Suppose you had a 13 hour clock, labeled 0 to 12. Start at 0 and go counterclockwise 104
hours (since you went counterclockise, that's -104 hours. Youl'll find
yourself ack at 0 (since 104/13=8). But wait, we
went too far, so go clockwise 3 hours and we'll see that the clock
reads 3 for -101 hours.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 26 ·
Replies
26
Views
3K
  • · Replies 53 ·
2
Replies
53
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
Replies
10
Views
5K