-3 mod 26 calculation?

  • Thread starter shivajikobardan
  • Start date
  • Tags
    Calculation
The simplest concept of a remainder is usually defined as a non-negative integer (although not always).In the usual case, we would have:$$-3 = (-1 \times 26) + 23$$As a simple analogy, I like to think in terms of a 12 hour clock.Clocks read hours as 1,2,3,4,5,6,7,8,9,10,11,12 only.Hence -3 hours would be 9 o'clock.f
  • #1
Summary: calculating modulo i.e remainder when -3 divided by 26

The answer seems to be (26-3)mod26=23. But I'm not sure how? Is there some rule like that? I don't quite get it.
 
  • #2
Summary: calculating modulo i.e remainder when -3 divided by 26

The answer seems to be (26-3)mod26=23. But I'm not sure how? Is there some rule like that? I don't quite get it.
What do you think it should be?
 
  • #3
Summary: calculating modulo i.e remainder when -3 divided by 26

The answer seems to be (26-3)mod26=23. But I'm not sure how? Is there some rule like that? I don't quite get it.

Related question: What's the integer part of -3/26? Is it [tex]
\left\lfloor - \frac{3}{26} \right\rfloor = -1\qquad\mbox{or}\qquad-\left\lfloor \frac{3}{26} \right\rfloor = 0?[/tex] If you use the first definition, then the remainder is [tex]
R(x) = x - 26\left\lfloor \frac{x}{26}\right\rfloor[/tex] and you would have [tex]R(-3) = -3 - 26(-1) = 23.[/tex] Alternatively if you use the second approach then [tex]
R(x) = x - 26\operatorname{sgn}(x)\left\lfloor \frac{|x|}{26}\right\rfloor[/tex] and you would get [itex]R(-3) = -3[/itex].
 
  • #4
What do you think it should be?
I think it should be -3 itself. As it's not divisble by 26. Just like if it was 3%26, it'd be 3.
 
  • #5
Summary: calculating modulo i.e remainder when -3 divided by 26

The answer seems to be (26-3)mod26=23. But I'm not sure how? Is there some rule like that? I don't quite get it.
##a \equiv b ## (mod ## n ##) means that ##(a-b)## is an integer multiple of ##n## i.e. ##a-b = kn## for some integer ##k##. You can also phrase this as a and b have same remainer when dividing with n: a = pn + ra and b = qn + rb. But if ra = rb then you have that a-b = (p-q)n = kn i.e. a-b is an integer multiple of n.

Therefore, you can always add or subtract any integer muptiple of ##n## to either ##a## or ##b##, for instance
if ##a \equiv b ## (mod ## n ##) , then:
##a \equiv b + n ## (mod ## n ##)
##a + n\equiv b ## (mod ## n ##)
etc
So in your case, you can add 26 to -3, you can add 52, subtract 26, subtract 52 and so on, and still have the same remained when dividing with 23
 
Last edited:
  • #6
I think it should be -3 itself. As it's not divisble by 26. Just like if it was 3%26, it'd be 3.
What are the possible answers for a "remainder" on division by 26? Is it the set ##\{-25, -24 \dots -1, 0, 1, \dots 24, 25\}##?

PS how is "remainder" defined?
 
  • Like
Likes malawi_glenn
  • #7
##a \equiv b ## mod##(n)## means that ##(a-b)## is an integer multiple of ##n## i.e. ##a-b = kn## for some integer ##k##.
I think you mean ##a \equiv b \pmod n ## means that ##(a-b)## is an integer multiple of ##n## i.e. ##a-b = kn## for some integer ##k##. The placing of the parentheses (in this case automatic through use of the \pmod symbol) is important.

However the OP is asking about something subtly different, the value of b where ## b = a \text{ mod } n ##. This is defined as the unique integer ## b \in \{0 \dots n-1\} ## for which ##a \equiv b \pmod n ## is true: for positive integers this is the same as the remainder on division by ## n ## but for negative integers this is not the case.
 
Last edited:
  • Like
Likes malawi_glenn, vela and topsquark
  • #8
Yes i wrote the paranthesis wrong thanks
 
  • #9
If we are talking about modular arithmetic, then technically ##-3## is the additive inverse of ##3##, which is ##23## in this case. So:$$-3 \equiv 23 \ (mod \ 26)$$The simpler concept of a remainder is usually defined as a non-negative integer (although not always). In the usual case, we would have:
$$-3 = (-1 \times 26) + 23$$
 
  • Like
Likes SammyS, FactChecker, topsquark and 1 other person
  • #10
As a simple analogy, I like to think in terms of a 12 hour clock.

Clocks read hours as 1,2,3,4,5,6,7,8,9,10,11,12 only.

Hence -3 hours would be 9 o'clock.
 
  • Like
Likes malawi_glenn and shivajikobardan
  • #11
1660752052057.png
 
  • Like
Likes shivajikobardan
  • #12
However the OP is asking about something subtly different, the value of b where ## b = a \text{ mod } n ##. This is defined as the unique integer ## b \in \{0 \dots n-1\} ## for which ##a \equiv b \pmod n ## is true: for positive integers this is the same as the remainder on division by ## n ## but for negative integers this is not the case.

Never seen ## b = a \text{ mod } n ## in my life, that you use an equal sign that is.
I have seen it when you deal with equivalence classes though.

I have only seen it being stated like this
"Find the smallest positive integer ##x## that solves ##x \equiv -18 \pmod {12}##"
or
"What is the smallest positive remainder when -18 is divided by 12" or "principal remainder"
 
  • #15
Some programming languages use the % operator for modulo operations.

x = 25 % 15
 
  • Like
Likes shivajikobardan
  • #17
yes it's CS. didn't know math and CS were different for modulo.
Writing a = b (mod n) is an abomination!
 
  • #18
Writing a = b (mod n) is an abomination!
Yes it would be, but no-one has done that. As I said, parentheses (and the equivalence relation vs equality) are important here to distinguish between the two forms.
 
  • #19
Yes it would be, but no-one has done that. As I said, parentheses (and the equivalence relation vs equality) are important here to distinguish between the two forms.
You did so in post 7.
However the OP is asking about something subtly different, the value of b where b=a mod n.
Never seen that notation.
 
  • #20
  • #21
yes it's CS. didn't know math and CS were different for modulo.
How a computer language works is at the discreption of the developers of that language. In Python, for example:
$$-3\%26 = 23$$Which is what I would have hoped.
 
  • Like
Likes malawi_glenn
  • #22
More correctly in Python the expression would be:

Python:
-3%26 == 23

as single equals is for assignment x-y ie assign the value of y to x.

and double equals is for equality as in x==y meaning the value of x is equal to the value of y

An example python program:

Python:
for x in range(-50,50):
    y=x%26
    print("%d  %d"%(x,y))

One thing to note in python is that the % operator takes on different uses depending on how it is used:
- as a modulo operator y=x%26
- as a format specifier as in %d for printing an integer
- as a string formatting operator to apply the tuple to the format string "%d %d"
 
  • Sad
  • Like
Likes malawi_glenn and PeroK
  • #23
This was my Python program:
Python:
print(-3%26)
 
  • Like
Likes malawi_glenn

Suggested for: -3 mod 26 calculation?

Replies
13
Views
554
Replies
1
Views
546
Replies
6
Views
866
Replies
7
Views
943
Replies
53
Views
681
Replies
3
Views
848
Replies
15
Views
2K
Replies
2
Views
458
Back
Top