Signed Number Representation: Sign-Magnitude, 1’s Complement, and 2’s Complement
Signed number representations encode negative integers in binary by dedicating meaning to the most significant bit(s) and by defining arithmetic rules for addition/subtraction. The three classical schemes are:
- Sign-magnitude: sign bit + magnitude bits.
- One’s complement: yields two zeros.
- Two’s complement: yields a single zero and enables straightforward addition.
A conceptual view is: each representation defines (1) how to encode values into bits and (2) what binary addition does with encoded operands. In hardware, the key practical goal is to make addition logic uniform and simple across signs, while minimizing special cases like multiple zeros or extra correction steps.
Important note: Due to a tooling limitation, web citations could not be retrieved for this run. As a result, the required inline citation system ($$ style) and footnotes could not be produced. The content below is still technically accurate, but you should verify against a textbook or reference during production.
Core definitions to keep consistent
- MSB is typically the sign-related bit.
- Bitwise complement defines one’s complement negativity.
- Carry/overflow affects meaning near limits.
Signed Binary: Sign-Magnitude vs 1's Complement vs 2's Complement
How each scheme represents negatives (encoding rules)
1) Sign-magnitude
In an -bit word:
- The sign bit determines polarity: typically for nonnegative, for negative.
- The remaining bits store the absolute value (“magnitude”).
If , encode magnitude directly. If , encode the magnitude and set the sign bit to .
Consequence: arithmetic must explicitly handle differing sign bits; raw unsigned addition does not directly equal signed addition.
2) One’s complement
Define nonnegative normally in bits. To represent a negative value:
- Compute the bitwise complement of the positive representation.
Equivalently, if is the -bit pattern for , then the -bit pattern for is .
Consequence: there are two encodings for zero:
- is all zeros.
- is all ones.
Addition also has a special rule: if there is a carry out of the most significant bit, it must be added back (“end-around carry”)—this is a correction step not present in two’s complement.
3) Two’s complement
Again, encode nonnegative normally. For negative values:
- Take the one’s complement and add .
Equivalently: if is the -bit pattern for , then is the bitwise complement of plus (modulo ).
Consequence: there is a single zero representation (all zeros), and addition can use standard binary adders with wraparound; the hardware behavior corresponds to signed arithmetic interpretation within the representable range.
[s][magnitude bits] s=0 → +x s=1 → -x magnitude = |x|
Visualizing the bit patterns around zero
Even without choosing an explicit bit-width, each scheme’s “shape” differs near zero and affects arithmetic correctness and simplicity.
Advantages/Disadvantages by Scheme (qualitative)
A quick comparison across practical engineering concerns (higher is better for the 'advantage' qualities).
Advantages and disadvantages (deep, engineering-focused)
Sign-magnitude
Advantages
- Direct interpretability: you can interpret magnitude and sign separately.
- Negation operation can be as simple as flipping only the sign bit (with magnitude unchanged).
Disadvantages
- Two encodings of zero: both “+0” and “−0” exist, which complicates equality checks and some arithmetic edge cases.
- Arithmetic complexity: standard addition of bit patterns does not directly correspond to signed addition across sign changes without additional handling.
- Overflow behavior is less “natural” for pure adder hardware; designers typically prefer representations where the same adder works for signed addition.
One’s complement
Advantages
- Negation via bitwise NOT: is the bitwise complement of .
- Addition hardware can be close to standard addition, but with one correction conceptually tied to end-around carry.
Disadvantages
- Two zeros persist: and both exist.
- End-around carry correction: addition requires an additional step when there is carry out, complicating circuits compared with two’s complement.
- Some comparison and normalization logic can become more intricate because of the second zero representation.
Two’s complement
Advantages
- Single zero eliminates ambiguity and simplifies equality/edge-case logic.
- Uniform addition: two’s complement arithmetic corresponds to standard binary addition modulo , and overflow can be detected/handled using sign-bit rules.
- Hardware efficiency: widely supported by CPU/ALU design.
Disadvantages
- Asymmetric range: for bits, the representable range is typically to , so the negative side has one extra magnitude compared with positive.
- Overflow wraparound: two’s complement addition “wraps” in the modular sense, so overflow detection is necessary for correctness in bounded arithmetic.
- Negation not just sign flip: while there are fast methods, negating in general involves the complement plus one rule, not just flipping a single bit (unlike sign-magnitude’s simple sign-bit flip).
Negation and representation workflow for each scheme (on an n-bit word)
- 1Step 1
Fix bits. Decide what integer range you must support.
- 2Step 2
Write in binary using bits (standard unsigned encoding).
- 3Step 3
For , keep magnitude bits as for and flip the sign bit to 1.
- 4Step 4
For , compute the bitwise NOT of the -bit pattern for .
- 5Step 5
For , compute bitwise NOT of and then add 1 (modulo ).
- 6Step 6
Sign-magnitude and one’s complement admit multiple zero encodings; two’s complement admits a single zero encoding.
- 7Step 7
Sign-magnitude and one’s complement require sign-aware or correction logic; two’s complement works with standard addition plus overflow detection.
Common edge cases and misconceptions
Why two’s complement became dominant
Clarity-first thinking
Sign-magnitude eraSeparate sign and magnitude was intuitive, but arithmetic required extra logic."
Bitwise negation and partial hardware reuse
One’s complement adoptionNegation became simple (~P), but the end-around carry and two zeros remained."
Uniform addition with fewer special cases
Two’s complement standardizationSingle zero and standard adder behavior made it practical for ALUs."
Signed representations quick checks
Knowledge Check
Which representation can have two different bit patterns that both represent the numeric value 0?