User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
0b
0b
Quick Presets
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

The bitwise OR operation compares each bit position of two binary operands: if either bit is 1, the result bit is 1. Only when both bits are 0 does the output yield 0. This operation is foundational in register-level programming, permission flag systems, and subnet mask calculations. Misapplying OR where XOR or AND is required leads to silent data corruption - flags get set that should remain clear, and bitmask filters pass values they should reject. This calculator accepts operands up to 64 bits, computes the OR using native integer arithmetic, and displays the bit-by-bit truth table so you can audit every position.

The tool outputs results simultaneously in binary, decimal, hexadecimal, and octal. It assumes unsigned integer representation. For signed interpretation, the most-significant bit would require two's complement conversion, which this tool does not perform. Pro tip: when combining Unix file permission masks (e.g., 0644 | 0111 = 0755), always verify the result against your security policy before applying chmod.

bitwise OR binary calculator bitwise operations OR gate binary math bit manipulation

Formulas

The bitwise OR operation is defined per bit position i across two unsigned binary integers A and B:

Ri = Ai โˆจ Bi

Where Ri is the result bit at position i, and โˆจ is the logical disjunction. The full integer result is reconstructed as:

R = nโˆ’1โˆ‘i=0 Ri โ‹… 2i

Where n = total number of bit positions (determined by the longer operand). Equivalently, for full integers: R = A | B. Key algebraic properties of bitwise OR:

A | 0 = A (identity)
A | A = A (idempotent)
A | ยฌA = 1...1 (all ones)
A | B = B | A (commutative)

Where A = first binary operand, B = second binary operand, R = result, i = bit index (LSB = 0), n = bit width.

Reference Data

ABA | BDescription
000Both bits clear โ†’ result clear
011One bit set โ†’ result set
101One bit set โ†’ result set
111Both bits set โ†’ result set
Bit WidthMax Unsigned ValueCommon UseAll-Ones Mask
4-bit15Nibble, hex digit1111
8-bit255Byte, ASCII, color channel11111111
12-bit4095ADC resolution, Unix permissions (octal)111111111111
16-bit65535Short integer, Unicode BMP1111111111111111
24-bit16777215RGB color (#FFFFFF)111111111111111111111111
32-bit4294967295IPv4 address, int3211111111111111111111111111111111
48-bit281474976710655MAC address48 ones
64-bit18446744073709551615Long integer, memory address64 ones
OperationSymbolTruth whenIdentity elementCommon mnemonic
AND&Both 11 (all ones)Masking / clearing bits
OR|Either 10Setting / combining flags
XORโŠ•Bits differ0Toggling / checksums
NOTยฌInvertN/AComplement / inversion
Left Shift<<Multiply by 2n0Fast power-of-two multiply
Right Shift>>Divide by 2n0Fast power-of-two divide

Frequently Asked Questions

Bitwise OR (|) operates on each bit position independently across two integers. Logical OR (||) evaluates entire expressions as boolean true/false and short-circuits: if the left operand is truthy, the right operand is never evaluated. For example, 6 | 3 = 7 (binary 110 | 011 = 111), while 6 || 3 = 6 (returns the first truthy value). Confusing the two in C/C++ flag manipulation is a common source of bugs.
The shorter operand is implicitly zero-padded on the left (most-significant side) to match the longer operand's width. This is equivalent to treating the shorter number as having leading zeros. For instance, 101 (3-bit) OR'd with 11001 (5-bit) becomes 00101 | 11001 = 11101. This calculator performs that alignment automatically.
Because A | 0 = A for any value of A. OR-ing with 0 never sets any new bits, leaving the original value unchanged. This contrasts with AND, whose identity element is all-ones (1...1), because A & 1...1 = A.
No. Since OR only sets bits to 1 (never clears them), the result is always greater than or equal to the larger of the two operands. Formally: A | B โ‰ฅ max(A, B). This property makes OR useful for accumulating permission flags - once a flag is set, no subsequent OR operation can remove it.
In IPv4 networking, the broadcast address of a subnet is computed by OR-ing the network address with the inverted subnet mask. For example, network 192.168.1.0 with mask 255.255.255.0: the inverted mask is 0.0.0.255 (00000000.00000000.00000000.11111111 in binary). OR-ing gives broadcast address 192.168.1.255. An incorrect mask inversion leads to packets being sent to the wrong broadcast domain.
No. This calculator treats all inputs as unsigned binary integers. In two's complement, the MSB represents the sign bit, and OR-ing two negative numbers can produce unexpected positive results if you don't account for the fixed bit-width. If you need signed interpretation, first determine your target bit-width (e.g., 8, 16, 32), pad both operands to that width, then interpret the OR result's MSB as the sign bit manually.