Use this bitwise OR calculator to compare bits and return 1 where either bit is 1. OR is commonly used for setting bits and combining flags.
Bitwise OR calculator
Using the calculator
Enter two numbers and select an input format for each: Decimal, Hex, Binary, or Octal. You can also type prefixes directly (0xFF for hex, 0b1010 for binary, or 0o17 for octal) and the tool will auto-detect the format.
The result displays in all formats simultaneously: decimal (signed and unsigned), hexadecimal, octal, and a 32-bit binary representation with spaces every 8 bits for readability.
How bitwise OR works
Bitwise OR (written as |) compares each bit of two numbers. It returns 1 if either bit is 1, and 0 only if both bits are 0. Think of it as "at least one must be true."
The OR truth table:
| A | B | A | B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Bitwise OR example
Comparing the binary representations bit by bit:
00101100 (44)00011000 (24)
────────00111100 (60)
Any position with at least one 1 becomes 1 in the result. In other words: 44 | 24 = 60.
Common uses for OR
Set bits: OR with a mask to turn on specific bits. For example, flags | 0x04 sets bit 2 regardless of its previous state.
Combine flags: Multiple flags can be combined into one value: READ | WRITE | EXECUTE
Pack values: Combine separate values into a single integer. For 24-bit RGB colors: (red << 16) | (green << 8) | blue
Set bit unconditionally: x | (1 << n) sets bit n to 1 regardless of its current value.
