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

  • Context: Undergrad 
  • Thread starter Thread starter dynamoliljosh
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
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