How the OR Calculator works
This tool computes the bitwise OR of two whole numbers. Bitwise OR compares two numbers one binary digit (bit) at a time: the result has a 1 in a given position if either number has a 1 in that same position, and a 0 only when both numbers have a 0 there. It is one of the four fundamental logic operations in computing, alongside AND, XOR, and NOT.
Formula and method
For each bit position, the result bit follows a simple rule: result = 1 when A or B (or both) has a 1 in that position; the result bit is 0 only when both are 0. That gives the single-bit truth table 0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, 1 OR 1 = 1. To compute A OR B for whole numbers, write both numbers in binary padded to the same length, then apply this rule to every column independently. For example, 12 (1100 in binary) OR 10 (1010 in binary) gives 1110 in binary, which is 14 in decimal — a column produces a 1 whenever at least one of the two numbers had a 1 there.
Common sources of error
- Bit width too small: a number that does not fit the selected bit width is rejected rather than silently truncated — choose 16-bit or 32-bit for larger values.
- Confusing OR with AND: OR only requires one bit to be 1; AND requires both. Swapping them produces the wrong mask when setting versus clearing bits.
- Misreading bit order: bit 0 is the rightmost (least significant) bit, not the leftmost, in standard binary notation.
Checking your result
A quick sanity check: A OR B can never be smaller than the larger of A and B, because OR only ever sets bits — it never clears a bit that was already 1 in either operand. If a computed result is less than max(A, B), something is wrong. You can also verify small examples by hand: write both numbers in binary, align the columns, and OR each column individually.
Applications
Bitwise OR is used throughout computing: turning on specific flag or permission bits without disturbing others, merging two sets of binary options into one value, combining color or pixel data, computing a broadcast address from a network address and the inverse of a subnet mask, and building a bitmask by ORing together individual bit values.