Skip to content
FiftyCalc Free calculators for all 50 states

Bitwise OR Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter two whole numbers to combine them bit by bit with OR (and see AND and XOR too).

Result

Sample figures

a OR b—

a AND b —

  • a XOR b—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Bitwise OR Calculator

First number (whole, 0 to 4,294,967,295): enter a number from 0 to 4,294,967,295. Prefilled example: 12.

Second number (whole, 0 to 4,294,967,295): enter a number from 0 to 4,294,967,295. Prefilled example: 10.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. First number (whole, 0 to 4,294,967,295): enter a number from 0 to 4,294,967,295.
  2. Second number (whole, 0 to 4,294,967,295): enter a number from 0 to 4,294,967,295.
  3. Read the result: a OR b; the panel also shows a AND b and a XOR b.

How this calculator works

Both numbers are written in binary (base 2). OR gives 1 in each bit position where at least one of the two numbers has a 1; AND only where both have a 1; XOR (exclusive or) where exactly one has a 1.

Each bit k of a number x is ⌊x ÷ 2ᵏ⌋ mod 2; the result adds 2ᵏ for every position that comes out as 1. These are the operators of Boolean algebra applied to each bit, as in the | & ^ operators of most programming languages (unsigned, 32 bits).

Worked example

First number (whole, 0 to 4,294,967,295)12
Second number (whole, 0 to 4,294,967,295)10
a OR b14
a AND b8
a XOR b6

Frequently asked questions

What is 12 OR 10?

12 is 1100 and 10 is 1010 in binary, so 12 OR 10 = 1110 = 14. 12 AND 10 = 1000 = 8 and 12 XOR 10 = 0110 = 6.

Is OR the same as adding?

Only when the numbers share no 1 bits: 255 OR 256 = 511 = 255 + 256. Otherwise OR is smaller than the sum.

Related calculators