Boolean & Modulo: (a&b)modp - Is it the same as (amodp)&(bmodp)?

  • Context: Undergrad 
  • Thread starter Thread starter dynamoliljosh
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the equivalence of two expressions involving the bitwise AND operator and the modulo operation: specifically, whether (a&b) mod p is the same as (a mod p) & (b mod p). The scope includes mathematical reasoning and exploration of counterexamples.

Discussion Character

  • Exploratory, Mathematical reasoning, Debate/contested

Main Points Raised

  • One participant asks if (a&b) mod p is equivalent to (a mod p) & (b mod p) and requests further information.
  • Another participant asserts that the two expressions are not equivalent, providing the example of 6&5 mod 11.
  • A subsequent reply questions the validity of the counterexample, showing that both expressions yield the same result of 4 in this case.
  • A further example is presented with (4&5) % 3 and (4%3) & (5%3), which yields different results, suggesting a lack of equivalence.

Areas of Agreement / Disagreement

Participants do not reach a consensus; there are competing views regarding the equivalence of the two expressions, with examples provided that both support and challenge the initial claim.

Contextual Notes

The discussion highlights potential limitations in understanding how the bitwise AND and modulo operations interact, particularly in different numerical contexts.

dynamoliljosh
Messages
1
Reaction score
0
Please do you know if (a&b)modp(where &stands for bitwise boolean AND operator)is the same as (amodp)&(bmodp)?Or can you direct me to somewhere i can find more information on this?Thanks.
 
Mathematics news on Phys.org
No, consider 6&5 mod 11.
 
Eynstone said:
No, consider 6&5 mod 11.
How is this a counterexample?
(6 & 5) % 11 == 4 % 11 == 4
(6 % 11) & (5 % 11) == 6 & 5 == 4

(Since you're using the C/C++ bitwise AND operator, I'm using the C/C++ modulus operator, %.)
 
How about:

(4&5) % 3 == 4 % 3 == 1
but
(4%3) & (5%3) == 1 & 2 == 0
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 12 ·
Replies
12
Views
8K
  • · Replies 7 ·
Replies
7
Views
2K