Advertisement

OR calculator

Set every bit that appears in either input. Compare a pair of patterns and read their inclusive OR in binary, octal and signed or unsigned decimal.

Calculator

Binary result
00001110
Octal result
16
Unsigned decimal
14
Signed decimal (two's complement)
14
One operation per bit
PositionABResult
7000
6000
5000
4000
3111
2101
1011
0000

Advertisement

How this calculator works

OR combines flags. A set bit in either operand stays set in the result, including positions where both inputs are 1. Inputs must fit the selected width. Short binary patterns receive leading zeros. Decimal negatives use two's complement and must be at least -2^(n-1). The signed output interprets the top bit as a negative place value; the unsigned output reads the same pattern as nonnegative.

Formula

At each position, a OR b = a + b - ab. Only the pair (0, 0) produces 0.

Worked example

In four bits, 1100 OR 1010 = 1110. This is 12 OR 10 = 14 in decimal.

Advertisement

Frequently asked questions

How is OR different from ordinary arithmetic?

It acts separately on each bit position without carrying between columns. The table shows the input pair and output bit for every position.

What happens at the limits?

OR with zero leaves the pattern unchanged; OR with all ones produces all ones.

Can I use more than 32 bits?

Yes. Choose a preset through 64 bits or a custom width from 1 to 256. Text entry preserves every digit, including leading zeros.

Why can signed and unsigned results differ?

They interpret one stored pattern differently. If its highest bit is 1, two's complement subtracts 2^n from the unsigned value.

Sources

Advertisement