Signed Number Representation — Digital Logic
🧮 Basics of Digital Logic (Signed Number Representation)
Let’s start with a simple thought:
When you say +5 or –5, what’s really happening? The “+” and “–” signs tell us the direction of the number — positive or negative.
Humans understand this easily.
But computers? They only understand 0s and 1s.
So how do they represent negative numbers using just those two symbols?
That’s exactly what signed number representation is all about.
💡 Unsigned vs Signed Numbers
Before we dive deeper, let’s clear one thing up.
- Unsigned numbers are only positive (like 0, 1, 2, 3, 4…).
In binary, 4 bits can represent numbers from 0 to 15. - Signed numbers, on the other hand, can be positive or negative.
The most significant bit (the leftmost one) is used to show the sign: 0→ positive number1→ negative number
This leftmost bit is often called the sign bit.
🧭 1. Sign-Magnitude Representation
This is the simplest way to represent signed numbers.
Here’s how it works:
- The first bit represents the sign.
- The remaining bits show the magnitude (the absolute value).
For example, using 4 bits:
| Decimal | Binary | Explanation |
|---|---|---|
| +5 | 0101 | 0 = positive, 101 = 5 |
| -5 | 1101 | 1 = negative, 101 = 5 |
So simple, right?
But there’s a small problem — we have two zeros:+0 = 0000 and –0 = 1000.
Computers don’t like having two versions of zero. It confuses things!
🔁 2. 1’s Complement Representation
To fix that issue a bit, we came up with 1’s complement.
Here’s the rule:
- Positive numbers stay the same.
- To get a negative number, flip every bit (change 0 → 1 and 1 → 0).
Example with 4 bits:
| Decimal | Binary |
|---|---|
| +5 | 0101 |
| -5 | 1010 (the 1’s complement of 0101) |
This method is better, but it still has two zeros:+0 = 0000 and –0 = 1111.
So, still not perfect.
🔄 3. 2’s Complement Representation
Now comes the star of the show — 2’s complement, the method almost every modern computer uses.
Why?
Because it solves the double-zero problem and makes arithmetic easier for the computer.
Here’s how it works:
- Start with the positive number’s binary.
- Invert all the bits (find the 1’s complement).
- Add 1 to the result.
Let’s take +5 again (4 bits):
+5 = 0101
1’s complement = 1010
Add 1 → 1011
So, –5 = 1011 in 2’s complement.
Now, check this out:
When you add +5 and –5 using binary, you get 0000 (zero)!
That’s the magic — no separate “+0” or “–0.” Just one zero.
Computers love that kind of neatness.
🧠 Example: Range of Numbers
If you’re using 4 bits, here’s how far you can go:
| Representation | Range |
|---|---|
| Unsigned | 0 to 15 |
| Sign-Magnitude | –7 to +7 |
| 1’s Complement | –7 to +7 |
| 2’s Complement | –8 to +7 |
Notice how 2’s complement gives one extra negative number.
That’s another reason why it’s so popular.
🔍 Quick Analogy
Imagine you have a circular number line — like a clock.
When you use 2’s complement, going below zero just loops around from the top.
That “wrap-around” behavior is what makes binary math so smooth and efficient for computers.
⚙️ Why It Matters
Signed number representation is at the heart of computer arithmetic.
Every calculation your phone or laptop performs — temperature changes, sound waves, or image brightness — often involves positive and negative values.
Without this system, computers wouldn’t know how to handle negatives at all!
- Signed numbers let computers represent both positive and negative values.
- Sign-magnitude is simple but gives two zeros.
- 1’s complement improves it slightly but still has two zeros.
- 2’s complement is the best — it’s efficient, clean, and easy for hardware to handle.
- Modern digital systems almost always use 2’s complement representation.
