Understanding Bitwise OR
The bitwise OR operation takes two operands and performs a logical OR operation on each pair of corresponding bits. If either bit in the operands is set (1), the corresponding bit in the result will also be set (1). Otherwise, the bit will be cleared (0). Here’s a quick overview of the bitwise OR truth table:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
Table of Content
- Using Brute Force
- Optimised Approach
JavaScript Program to Compute the Bitwise OR of all Numbers in a Range
In JavaScript, bitwise operations provide a way to manipulate individual bits of numeric values. The bitwise OR operation (|) combines the bits of two operands, resulting in a new value where each bit is set if it is set in either operand.