or Calculator - Bitwise OR, Truth Table, and Result

Use this or calculator to apply the bitwise OR to two numbers in binary, octal, decimal, or hex at 4, 8, 12, or 16 bits, with the 2-input truth table.

Updated: June 16, 2026 • Free Tool

or Calculator

Enter the first operand in the chosen base. Decimal, binary, octal, and hexadecimal values are all accepted.

Enter the second operand in the same base as Number 1.

Numerical base of the two input fields. 2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal.

Number of bits used to represent each input. The result is masked to this width.

Results

OR Result (Decimal)
0
OR Result (Binary) 0
OR Result (Octal) 0
OR Result (Hexadecimal) 0
2-Input OR Truth Table
A B A OR B
000
011
101
111

What Is an or Calculator?

An or calculator returns the bitwise OR of two numbers by applying the OR rule to each pair of corresponding bits. Type the two operands in binary, octal, decimal, or hex, choose a bit width, and the result panel shows the OR in decimal, binary, octal, and hex, with the 2-input truth table right next to it. Within the chosen bit width the OR result is at least either input, because OR never clears a set bit.

  • Combining bit flags: Merge two flag words such as 0x01 (READ) and 0x04 (WRITE) into a single 0x05 (READ + WRITE) permission mask in one step.
  • Setting specific bits in a register: Turn a particular bit on without changing the others by ORing the current value with a mask that has 1s only at the desired positions.
  • Hardware register and IOCTL programming: Assemble a register value from individual control bits and combine IOCTL direction and option flags into a single command word.
  • Boolean algebra homework and truth tables: Verify the result of a 2-input OR expression, or work through the truth table for an OR of two Boolean variables.

The bitwise OR is one of the four foundational bitwise operators in most languages, alongside AND, XOR, and NOT, and it operates one bit at a time.

If you also need AND, XOR, or NOT on the same pair of numbers, the Binary Operations Calculator runs all of the bitwise operations side by side so the results are easy to compare.

How the or Calculator Works

The calculator parses the two inputs in the chosen base, masks each input to the bit width, applies the OR rule column by column, and formats the result. The 2-input OR truth table on the right is generated from the four fixed bit pairs (00, 01, 10, 11).

result_bit_i = A_bit_i OR B_bit_i (1 when at least one bit is 1, 0 only when both bits are 0)
  • A_bit_i: The bit at position i in Number 1, counted from the right starting at 0.
  • B_bit_i: The bit at position i in Number 2, counted from the right starting at 0.
  • result_bit_i: 1 when at least one of A_bit_i or B_bit_i is 1, and 0 only when both are 0.
  • bitWidth: The chosen number of bits (4, 8, 12, or 16). Inputs and the result are masked to this width so high bits are dropped.

The four bit pairs that drive the truth table are always the same: 0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, and 1 OR 1 = 1. A 16-bit OR is just sixteen 1-bit ORs in a row.

Decimal 21 OR decimal 25 (8-bit)

Number 1 = 21, Number 2 = 25, base = decimal, width = 8

21 in binary is 00010101 and 25 in binary is 00011001. Aligning them: 00010101 OR 00011001 = 00011101.

OR result: 29 in decimal, 00011101 in binary, 0o35 in octal, 0x1D in hex.

29 = 16 + 8 + 4 + 1 shows the union of the surviving bit positions.

Hexadecimal 0F OR hexadecimal F0 (8-bit)

Number 1 = 0F, Number 2 = F0, base = hex, width = 8

0F in binary is 00001111 and F0 in binary is 11110000. Aligning them: 00001111 OR 11110000 = 11111111.

OR result: 255 in decimal, 11111111 in binary, 0o377 in octal, 0xFF in hex.

Every bit is set in at least one input, so the result is 0xFF, the largest 8-bit value.

According to MDN Web Docs, the bitwise OR operator returns 1 in each bit position where one or both of the corresponding bits of the operands are 1, and 0 only where both are 0

According to Omni Calculator, the bitwise OR is computed by aligning two binary numbers to the right and applying the OR rule to each pair of bits, so 10101 OR 11001 equals 11101

To convert the inputs or the result between binary, octal, decimal, and hex without doing the math by hand, the Binary Converter accepts a value in any of those bases.

Key Concepts Behind the Bitwise OR

Four short ideas explain why the OR behaves the way it does and how it relates to the other tools on the site. Once these are clear, OR stops looking like a magic operator and starts looking like a column-by-column inclusion table.

Logical OR vs bitwise OR

Logical OR takes two Boolean values and returns a single Boolean. Bitwise OR applies that same true/false rule to every bit position in two binary numbers, so the result is also a binary number.

Truth table for a 2-input OR

For inputs A and B, the OR gate outputs 1 when at least one of A or B is 1, and 0 only when both are 0. The page renders that table next to the result.

OR in programming notation

Most languages use a single vertical bar for bitwise OR, written a | b, while logical OR uses a double bar a || b. Some languages spell the logical form as 'or' or 'OR'.

Setting bits with OR

OR with a constant that has 1s only in the positions you want to set acts as a setter. x | 0x80 forces the high bit on, and x | 0x0F turns on the low 4 bits.

The same rule extends to more than two inputs. A 3-input OR returns 1 when at least one bit at that position is 1, so a single 1 forces the column to 1. For full Boolean expressions with AND, OR, and NOT, the Boolean Algebra Calculator evaluates the expression and shows its truth table.

For full Boolean expressions that mix AND, OR, and NOT, the Boolean Algebra Calculator evaluates the expression and shows the truth table for the variables.

How to Use the or Calculator

Enter the two operands, pick the base they are written in, and pick the bit width. The result panel updates in real time as you change the inputs.

  1. 1 Type Number 1 and Number 2: Enter the two operands in the first row. They must use the same base. For decimal, type digits like 21 and 25. For binary, use only 0 and 1. For hex, you can also use A through F.
  2. 2 Pick the input base: Use the Input Base dropdown to select 2 (binary), 8 (octal), 10 (decimal), or 16 (hexadecimal). Both operands are read in this base.
  3. 3 Pick the bit width: Use the Bit Width dropdown to select 4, 8, 12, or 16. Values that overflow a smaller width have their high bits dropped, like a fixed-width register.
  4. 4 Read the OR result: The OR Result (Decimal) row shows the bitwise OR. The Binary, Octal, and Hex rows show the same value, with binary padded to the bit width and octal and hex prefixed with 0o and 0x.
  5. 5 Compare against the truth table: The 2-input OR truth table next to the result shows the four (A, B) bit pairs and their outputs. Any column in a longer binary OR follows one of those four rows.

Example: a developer needs a permission byte that combines READ (0x01) and EXECUTE (0x04). They type 1 into Number 1 and 4 into Number 2, leave the base at Hexadecimal, and read the result: 0x05 in hex, 0o5 in octal, 00000101 in binary, 5 in decimal.

When the next step is to add the combined flag value to another number, the Binary Addition Calculator performs binary addition with carry and returns the sum in the same base.

Benefits of Using This or Calculator

OR is one of the simplest operators to define, but mixing bases and bit widths by hand is the easy place to lose a bit. The calculator keeps the operands, base, and width consistent.

  • Bit-level result without manual alignment: The result panel shows the OR in decimal, binary, octal, and hex at the same time, so bits do not have to be aligned on paper.
  • Works in binary, octal, decimal, and hex: Type the operands in any of the four bases and the result appears in all four.
  • Bit-width masking matches real hardware: Choose 4, 8, 12, or 16 bits to mimic a fixed-width register. Values that overflow have their high bits dropped, like an OR with a width-sized mask in C, JavaScript, or Python.
  • Truth table next to the numeric result: The 2-input OR truth table is rendered on the page, so the numeric answer can be verified against the four (A, B) -> output rows.
  • Reusable for setting bits and combining flags: The same workflow covers permission bit sets (READ | WRITE), color channel assembly, and hardware register writes.

The biggest practical win is consistency: OR behaves the same way regardless of the input base, and the calculator applies that rule.

When the result is in binary and you need it in hex without doing the nibble grouping yourself, the Binary to Hexadecimal Calculator converts a binary string to its hex value in one step.

Factors That Affect the Result and Its Limits

The bitwise OR is fixed, but four choices about the inputs change what the result means. Knowing them up front prevents surprises from signed inputs or a smaller bit width.

Input base

The base only changes how the inputs are parsed, so 0xF0 in hex and 240 in decimal produce the same bitwise OR.

Bit width

4, 8, 12, and 16 bits set the size of the result. OR of 0xF0 and 0x0F in 4-bit width returns 0xF because the high nibble of 0xF0 is dropped, so the result is only assured to be greater than or equal to the masked inputs, not the original unmasked ones.

Sign of the inputs

The calculator treats the inputs as non-negative integers. A negative two's-complement input is out of scope; apply the two's-complement conversion first if you need signed bitwise behavior.

Invalid characters for the chosen base

A digit that is not allowed in the chosen base (such as a 2 in binary or a G in hex) fails to parse and the result falls back to 0 until the input is corrected.

  • The calculator takes exactly two operands. For three or more inputs, OR the first two and feed the result back in as Number 1 with the third value as Number 2, repeating until one value remains.
  • The inputs are read as non-negative integers, and the result is non-negative. For signed two's-complement integers, convert to the unsigned form, OR, and interpret the result as signed afterward.

When the inputs and the bit width are clear, the result matches what the same operation would produce in C, Java, JavaScript, or Python.

According to Wolfram MathWorld, the logical OR (disjunction) returns true when at least one operand is true, and is commutative, associative, and distributive over AND

When you need AND, OR, XOR, NOT, and shifts on the same pair of numbers in one view, the Bitwise Calculator runs all of the bitwise operations side by side.

or calculator showing the bitwise OR of two numbers in decimal, binary, octal, and hex with a 4/8/12/16-bit width and the 2-input OR truth table.
or calculator showing the bitwise OR of two numbers in decimal, binary, octal, and hex with a 4/8/12/16-bit width and the 2-input OR truth table.

Frequently Asked Questions

Q: What is the or calculator?

A: The or calculator returns the bitwise OR of two numbers. It accepts operands in binary, octal, decimal, or hexadecimal, applies the bit-by-bit OR at a chosen bit width, and shows the result in decimal, binary, octal, and hex alongside the 2-input truth table.

Q: How do you compute the bitwise OR of two numbers?

A: Write both numbers in binary, align them on the right, and apply the OR rule to each column. The result is 1 when at least one of the two bits is 1, and 0 only when both bits are 0. The calculator does that for you in real time.

Q: What is the truth table of an OR gate?

A: For two inputs A and B, the OR gate outputs 1 when A = 1 or B = 1 (or both). The output is 0 only on the single row where A = 0 and B = 0. The page renders that 2-input truth table directly.

Q: What is the difference between bitwise OR and logical OR?

A: Logical OR takes two Boolean values and returns a single Boolean. Bitwise OR applies that same Boolean rule to every bit position in two integers, so the result is also an integer.

Q: How many inputs can an OR gate have?

A: An OR gate can have any number of inputs. The output is 1 when at least one input bit at that position is 1, and 0 only when every input bit is 0. A single 1 input forces the output to 1 for that column.

Q: Why is the OR operation useful in programming?

A: OR is the standard way to set bits, combine permission flags into a single mask, assemble color channels into a packed RGB value, and merge option bits for an IOCTL or network call. The pattern x | mask is a common low-level idiom.