How does a computer know the difference between 11111101 being -3 and 253? The answer lies in signed number representation — specifically, the two’s complement system used in modern CPUs.
In a two’s complement system, the most significant bit (MSB) — the leftmost bit — represents the sign of the number:
-
0 = positive or zero
-
1 = negative
This allows the same binary adder circuits to handle both positive and negative values without needing separate subtraction hardware.
When working with 16-bit values:
-
Bits 0 through 14 represent the magnitude
-
Bit 15 (the highest bit) is used as the sign bit
The Less Than Zero circuit checks if this sign bit is HIGH (1):
-
If so, the number is negative
-
If it’s 0, the number is positive or zero
This is how a CPU determines that a number like 1111 1111 1111 1101 is actually -3, not 65533, based solely on the sign bit.
-
A simple wire connection to bit 15 (MSB) is used.
-
This bit acts as a flag:
-
1 → number is less than zero
-
0 → number is greater than or equal to zero
| Binary Value | Decimal Value | MSB | Less Than Zero? |
|---|---|---|---|
0000 0011 |
3 | 0 | ❌ No |
1111 1101 |
-3 | 1 | ✅ Yes |
1000 0000 |
-128 | 1 | ✅ Yes |
0111 1111 |
127 | 0 | ❌ No |
-
Two’s complement enables subtraction and negative values using the same binary adder
-
The most significant bit (MSB) doubles as the sign bit in signed integers
-
By checking just one bit, the CPU can determine whether a number is less than zero
-
This circuit becomes a key condition for branching, comparisons, and arithmetic checks in processors