c - What does this code do? -


 #include<stdio.h>   int main()  {     int i=4, j=8;        printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j);      return 0;  } 

the output : 12,12,12
why above output displayed ? can explain me ?

i | j&j | i bitwise or between i, i , j&j (& has priority on |). equivalent i | j, so:

i   = 0b00000100 = 4 j   = 0b00001000 = 8 i|j = 0b00001100 = 12 

i ^ j here same i | j since there no single bit set 1 both in j , i.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -