June 2017
Beginner
502 pages
11h 26m
English
The bitwise OR operator is similar to an inclusive OR and checks two integers using their binary representation: if there is at least a 1 on the same position for each number, the result will be 1:
zarrelli:~$ x=50 ; y=20; echo $((x|y))54
As we can see from the following table:
|
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
|
|
50 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
|
20 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
|
| |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
0 |
Read now
Unlock full access