Signed Integers: Sign-Magnitude Representation
What You'll Learn
You'll learn how computers use one bit to represent positive or negative signs, while the remaining bits store the magnitude of an integer.
The Core Idea
In hardware, unsigned integers use all available bits to represent only non-negative numbers (0, 1, 2, 3...). But real-world computing needs negative numbers too. Sign-magnitude representation solves this by dedicating the leftmost bit (the most significant bit) as a sign bit:
- 0 = positive (or zero)
- 1 = negative
The remaining bits store the magnitude (absolute value) of the number, just like unsigned integers.
How It Works
Imagine you have 4-bit numbers:
0011= +3 (sign bit is 0, magnitude is 011 = 3)1011= -3 (sign bit is 1, magnitude is 011 = 3)0000= +01000= -0 (yes, there are two representations of zero!)
Think of it like writing numbers with a plus or minus sign on paper: the sign is separate from the digits themselves.
Range
With n bits, sign-magnitude can represent values from -(2^(n-1) - 1) to +(2^(n-1) - 1).
For 8 bits: -127 to +127 (note: we "lose" two values because both +0 and -0 exist).
Why It Matters (and Why It's Rarely Used)
While intuitive, sign-magnitude has drawbacks: arithmetic is complicated (adding +3 and -5 requires special logic), and having two zeros wastes a bit pattern. Modern computers prefer two's complement for these reasons—but understanding sign-magnitude builds your foundation for why other representations evolved.
Key Takeaway: Sign-magnitude uses one bit for sign (0=positive, 1=negative) and the rest for magnitude, making negative numbers intuitive but arithmetic complex.