What is the Bitwise NOR Calculator?
This tool computes the bitwise NOR of two integers using the formula result = ~(A | B). NOR ("NOT OR") is a fundamental logic operation: it first performs an OR on each pair of corresponding bits, then inverts the result. An output bit is 1 only when both input bits are 0. NOR is functionally complete — every other logic gate can be built from NOR gates alone, which is why it is so important in digital electronics.
How to use it
Enter two whole numbers (A and B) and pick a bit width (8, 16, 32 or 64-bit). The calculator returns the NOR result interpreted as an unsigned value at that width, alongside the intermediate OR value and a binary representation. Choosing a smaller bit width simply masks off the higher bits, which is handy when you are emulating fixed-width registers.
The formula explained
The OR of two bits is 1 if either bit is 1. NOR inverts that, so each bit follows the truth table: 0 NOR 0 = 1, 0 NOR 1 = 0, 1 NOR 0 = 0, 1 NOR 1 = 0. Because the raw inversion (~) sets all the high bits, we mask the answer with \(2^n - 1\) to keep it inside the selected unsigned bit width.
$$\text{NOR} = \sim\left(\text{A} \mathbin{|} \text{B}\right) \mathbin{\&} \left(2^{\text{Bits}} - 1\right)$$
Worked example
Let A = 12 (binary 1100) and B = 10 (binary 1010) at 8-bit width. A | B = 1110 = 14. Inverting within 8 bits gives 11110001 = 241. So 12 NOR 10 = 241 at 8-bit width.
NOR Truth Table and Bit Width Masks
The bitwise NOR operation combines two operands bit by bit. For each pair of bits it first computes the OR, then inverts the result. In other words, an output bit is 1 only when both input bits are 0; in every other case the output bit is 0. This is the negation of OR, hence the name NOR (NOT-OR).
| A | B | A | B | NOR = ~(A | B) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 |
Because the NOT step inverts every bit, the result depends on the chosen bit width. After OR-ing the operands and inverting, the value is masked to the width \(n\) using \(2^{n}-1\), so that only the lowest \(n\) bits remain. The mask for each supported width is shown below.
| Bit width \(n\) | Mask \(2^{n}-1\) (decimal) | Maximum unsigned value |
|---|---|---|
| 8 | 255 | 255 |
| 16 | 65535 | 65535 |
| 32 | 4294967295 | 4294967295 |
| 64 | 18446744073709551615 | 18446744073709551615 |
For example, with \(A = 12\) and \(B = 10\) at 8-bit width: \(12 | 10 = 14\), and \(\sim 14\) masked to 8 bits gives 241. The intermediate OR result \(12 | 10 = \) 14 can be checked independently.
Key Terms
- Bitwise NOR
- An operation that produces a result whose every bit is 1 only when the corresponding bits of both operands are 0. It is defined as the inversion of the OR result: \(\text{NOR} = \sim(A | B)\).
- OR (bitwise)
- An operation that sets each result bit to 1 if at least one of the two corresponding input bits is 1, and to 0 only when both are 0.
- NOT / inversion (~)
- A unary operation that flips every bit: each 0 becomes 1 and each 1 becomes 0. In NOR it is applied to the OR result, and its effect is bounded by the chosen bit width.
- Bit width
- The number of bits used to represent a value (8, 16, 32, or 64 here). It determines how many bits the inverted result keeps and therefore the numeric range of the output.
- Masking
- Using a bitwise AND with a value like \(2^{n}-1\) to keep only the lowest \(n\) bits and discard higher bits. This confines the NOR result to the selected width.
- Unsigned integer
- A whole number representation with no sign bit, so all bit patterns represent non-negative values from 0 up to \(2^{n}-1\). The NOR result is reported as an unsigned value.
- Functionally complete (universal) gate
- A gate from which any Boolean function can be built using only copies of itself. NOR is functionally complete: AND, OR, and NOT can all be constructed from NOR gates alone, which is why it is called a universal gate.
FAQ
Why does the result change with bit width? Inversion flips every bit, so the leading 1s depend on how many bits represent the number. A wider width yields a larger unsigned result.
Can I use negative numbers? Inputs are treated as integers; for clean results use non-negative whole numbers within the chosen width.
Is NOR the same as NAND? No. NAND is ~(A & B) (NOT AND), while NOR is ~(A | B) (NOT OR). Both are universal gates but produce different outputs.