OR Calculator

Calculate the bitwise OR of two numbers.

Result: A OR B

Enter both values to see the result in decimal, hex, binary, and octal.

OR truth table
ABA OR B
000
011
101
111

OR Calculator – Bitwise Inclusive OR

Calculate the bitwise OR of two numbers and view the result in decimal, hexadecimal, binary, and octal. Enter the operands in any base (0x, 0b, and 0o prefixes are detected automatically) and see the bits of both inputs and the result lined up. For example 12 OR 10 = 14, because 1100 OR 1010 = 1110.

How OR works

OR returns 1 when at least one of the two bits is 1 and 0 only when both bits are 0. The operation is applied to each bit position separately. It is written a | b in C, C++, Java, C#, JavaScript, Python, Rust, and Go.

Setting bits with OR

Where AND is used to clear or test bits, OR is used to set them. Any bit that is 1 in the mask becomes 1 in the result, and all other bits keep their value:

  • flags | 0x04 switches on bit 2 without touching the rest.
  • O_WRONLY | O_CREAT | O_TRUNC combines file-open flags in POSIX.
  • (r << 16) | (g << 8) | b packs three color channels into one 24-bit RGB value.
  • network | ~netmask gives the broadcast address of a subnet.
  • Permission bits: 0o400 | 0o200 | 0o040 = 0o640 (rw-r-----).

OR vs. XOR

OR is sometimes called inclusive OR to distinguish it from XOR (exclusive OR). The difference is the case where both bits are 1: OR gives 1, XOR gives 0. So 12 OR 10 = 14, but 12 XOR 10 = 6. Try both with the XOR Calculator.

Width and negative values

Auto width picks the smallest multiple of 8 bits that holds both operands. Choose a fixed width (8–128 bits) to match a specific integer type; negative numbers are then written in two's complement before the OR is applied. The results table shows both the unsigned and signed interpretation of the result, and every value can be copied with one click. For all operations in one place, use the Bitwise Calculator.

Frequently Asked Questions

7. In binary 101 OR 011 = 111, because every position has at least one 1.

They differ only when both bits are 1: OR returns 1 and XOR returns 0. OR sets bits, XOR toggles them.

No. Logical OR works on true/false values and returns a boolean, while bitwise OR combines two integers bit by bit and returns a number.