sajad torkamani

The Bitwise OR operation – commonly expressed as the symbol |– takes two bit patterns of equal length and performs the logical inclusive OR operation on each pair of corresponding bits.

The inclusive OR operation works as follows:

Bit aBit bResult
0 00
011
101
111

If either of the bits is 1, the result is 1. Otherwise, the result is 0.

For example, you can apply the bitwise OR operation in JavaScript on the numbers 170 and 204 using:

170 | 204 
// 238

This is equivalent to:

   10101010 (170)
OR 11001100 (204)
-----------
   11101110 (238)
Tagged: Computing