Bitwise OR Operator (|)
a=10 b=11
Converting from Decimal to Binary:
Converting from Decimal to Binary:
a=10 à0000 1010
b=11
So
a=10->0 0 0 0 1010
b=11->0 0 0 0 1011
-----------
a|b= 0 0 0 0 1 0 1 1
----------
Binary to decimal:
0
|
0
|
0
|
0
|
1
|
0
|
1
|
1
|
27
|
26
|
25
|
24
|
23
|
22
|
21
|
20
|
--
|
--
|
32
|
16
|
8
|
4
|
2
|
1
|
0
|
0
|
0
|
0
|
8
|
0
|
2
|
1
|
a|b=0+0+0+8+0+2+1=11 (Add only 1's, and ignore 0s)
Truth Table:
a
|
b
|
a|b
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
Related Video: https://www.youtube.com/watch?v=a45kwVu3IU8&feature=youtu.be
Previous Topic: Bitwise AND Operator (&)
Next Topic: Bitwise Complement (~)
No comments:
Post a Comment