OR Calculator – Logical & Bitwise OR / XOR

Compute inclusive OR and exclusive OR (XOR) for up to 4 inputs — see truth tables, bit-by-bit visualization, binary/hex output, and Boolean algebra laws.

OR Result (Decimal)
15
10 OR 5
Result (Binary)
0b00001111
8-bit binary representation
Result (Hex)
0xF
Hexadecimal representation
Input A (Binary)
0b00001010
Decimal: 10 | Hex: 0xA
Input B (Binary)
0b00000101
Decimal: 5 | Hex: 0x5
Bit Width
8-bit
Range: 0 – 255

Bit-by-Bit Visualization

b7
0
0
OR
0
b6
0
0
OR
0
b5
0
0
OR
0
b4
0
0
OR
0
b3
1
0
OR
1
b2
0
1
OR
1
b1
1
0
OR
1
b0
0
1
OR
1
🔵 Input A🟡 Input B🟢 Result

Bit Breakdown Table

Bit PositionABA OR B
Bit 7000
Bit 6000
Bit 5000
Bit 4000
Bit 3101
Bit 2011
Bit 1101
Bit 0011

OR vs XOR Truth Table Reference

ABA OR BA XOR B
0000
0111
1011
1110

Boolean Algebra Laws (OR)

LawExpression
IdentityA OR 0 = A
NullA OR 1 = 1
IdempotentA OR A = A
ComplementA OR NOT A = 1
CommutativeA OR B = B OR A
Associative(A OR B) OR C = A OR (B OR C)
DistributiveA OR (B AND C) = (A OR B) AND (A OR C)
AbsorptionA OR (A AND B) = A
De MorganNOT(A OR B) = NOT A AND NOT B

Inclusive OR vs Exclusive OR

Inclusive OR (OR)

True when at least one input is true. Both true → still true.

Exclusive OR (XOR)

True when an odd number of inputs are true. Both true → false.

Planning notes, formulas, and examples

About the OR Calculator – Logical & Bitwise OR / XOR

The OR operation is the logical counterpart of "at least one condition is true." In Boolean algebra, inclusive OR returns true whenever one or more inputs are true, making it the natural choice for merging flags, combining search filters, or modelling union operations. Its sibling, exclusive OR (XOR), returns true only when an odd number of inputs are true — essential for parity checks, toggles, and simple encryption.

At the bitwise level, OR sets a bit in the result to 1 whenever at least one corresponding input bit is 1. This is commonly used to set specific bits in a register or to combine permission flags. XOR, on the other hand, flips bits where the inputs differ, making it invaluable for checksums, swapping values without a temporary variable, and error-detection codes.

This calculator supports both inclusive and exclusive OR in logical and bitwise modes with up to four inputs. Choose 4-, 8-, 16-, or 32-bit width and get the result in decimal, binary, and hex along with a colour-coded bit-by-bit visualisation. The side-by-side truth-table reference contrasts OR and XOR at a glance, and the Boolean-algebra-laws table summarises the identities you need for simplification. An explanation panel highlights the key difference between inclusive and exclusive OR. Whether you are debugging network code, studying digital logic, or simplifying Boolean expressions, the page keeps the symbolic and bit-level views aligned.

When This Page Helps

Bitwise OR and XOR look similar on paper but produce different results whenever both bits are 1, and mixing them up is a common source of bugs. This calculator shows inclusive OR and exclusive OR side by side, with full binary breakdowns for 8-, 16-, or 32-bit operands, so the difference is immediately visible. It supports up to four inputs and both logical (true/false) and bitwise (integer) modes, making it useful for flag manipulation, permission masks, checksum verification, and digital-logic homework.

How to Use the Inputs

  1. Choose between Bitwise OR and Logical OR mode.
  2. Select Inclusive OR or Exclusive OR (XOR).
  3. Set the number of inputs (2, 3, or 4).
  4. For bitwise mode, pick a bit width (4, 8, 16, or 32).
  5. Enter integer values for each input.
  6. Click a preset button for common examples.
  7. Review the output cards and bit-by-bit visualisation.
Formula used
OR: result bit = 1 if any input bit is 1 | XOR: result bit = 1 if odd number of input bits are 1

Example Calculation

Result: OR → 15 (0b1111), XOR → 15 (0b1111)

1010 OR 0101 = 1111 because at least one bit is 1 in each position. XOR gives the same result here since no position has both bits as 1.

Tips & Best Practices

  • Use OR to set specific bits: value | mask turns on bits wherever the mask has 1s.
  • XOR with the same value twice returns the original: A ^ B ^ B = A.
  • Inclusive OR is true when both inputs are true; exclusive OR is false in that case.
  • In programming, || is logical OR while | is bitwise OR — they short-circuit differently.

Inclusive OR vs. Exclusive OR

Inclusive OR outputs 1 when at least one input is 1, including the case where both are 1. Exclusive OR (XOR) outputs 1 only when the inputs differ. For bits 1 and 1: OR gives 1, XOR gives 0 — that single difference drives their distinct applications. In everyday language, "or" is usually inclusive ("tea or coffee" allows both), while "either … or" often implies exclusivity.

Practical Uses of Bitwise OR and XOR

Bitwise OR is the standard way to set flags: `permissions | WRITE_FLAG` turns on the write bit without disturbing others. XOR is used for toggling bits, simple encryption (XOR cipher), swap-without-temp (`a ^= b; b ^= a; a ^= b;`), and error-detection codes like CRC and parity. In networking, XOR of a set of RAID stripes produces the parity stripe, enabling single-disk recovery.

De Morgan's Laws and Gate Equivalences

De Morgan's Laws connect OR to AND through negation: NOT(A OR B) = (NOT A) AND (NOT B), and NOT(A AND B) = (NOT A) OR (NOT B). These identities let hardware designers convert between OR-based and AND-based circuits freely. XOR has its own identity family: A XOR B = (A AND NOT B) OR (NOT A AND B), and A XOR A = 0. Understanding these equivalences is essential for logic minimisation and circuit optimisation.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Inclusive OR is true when at least one input is true (including both). XOR (exclusive OR) is true only when the inputs differ — if both are true, XOR returns false.