Page 153 - Cs_withBlue_J_C11_Flipbook
P. 153
2. 10 | 7
10 = 1010 (In Binary)
7 = 0111 (In Binary)
Bit Operation of 10 | 7
1010
| 0111
00001111 which is 15 in decimal
Ans. 15
3. !5
5 = 0101 (In Binary)
!(5) = 1010 which is -5 in decimal
Ans. -5
4. 5 ^ 3
5 = 0101 (In Binary)
3 = 0011 (In Binary)
Bit Operation of 5 ^ 3
0101
^ 0011
0110 which is 6 in decimal
Ans. 6
5. ∼47
47 = 101111 (In Binary)
Bitwise complement Operation of 47
∼ 101111
010000 = 16 (In decimal)
Ans. 16
6. 12 | 25
12 = 01100 (In Binary)
25 = 11001 (In Binary)
Bitwise OR Operation of 12 and 25
01100
| 11001
11101 which is 29 in decimal
The following program demonstrates the use of bitwise operators:
151
Variables and Expressions 151

