By Dr. Sohel Rana

Chapter-1

.dld-wrap { font-family: ‘Segoe UI’, Tahoma, Geneva, Verdana, sans-serif; max-width: 1100px; margin: 0 auto; padding: 16px; background: #f0f4f8; color: #1a202c; box-sizing: border-box; } .dld-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 14px 0; } .dld-col { flex: 1 1 260px; min-width: 0; box-sizing: border-box; } .dld-chapter { background: #fff; border-radius: 14px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.07); } .dld-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; } .dld-table { border-collapse: collapse; width: 100%; font-size: 0.82rem; text-align: center; } .dld-table th, .dld-table td { padding: 6px 8px; border: 1px solid #ccc; } .dld-mono { font-family: ‘Courier New’, monospace; } .dld-box { background: #fff; border-radius: 8px; padding: 12px; margin-top: 8px; font-family: ‘Courier New’, monospace; font-size: 0.88rem; color: #2d3436; line-height: 1.8; } h2.dld-h2 { margin: 0 0 14px 0; font-size: 1.4rem; } @media (max-width: 600px) { .dld-wrap { padding: 10px; } h2.dld-h2 { font-size: 1.15rem; } .dld-chapter { padding: 14px; } .dld-box { font-size: 0.8rem; } .dld-col { flex: 1 1 100%; } }
🔢 NUMBER SYSTEMS
Complete Guide · Digital Logic Design (DLD)
Binary Octal Hexadecimal BCD & Gray Signed/Unsigned
📚 From Introduction to Advanced · With Daily Life Examples & Simple Tricks

🌟 Chapter 1 · Why Do We Need Number Systems?

Computers are machines made of tiny switches — only ON or OFF. Like a light switch! ON = 1, OFF = 0. This is the foundation of all computing. 💡

🏠
Decimal (Base 10)

What YOU use daily. Digits 0–9. Your age, money, phone number!

💻
Binary (Base 2)

What computers use. Only 0 & 1. On/Off switches inside chips!

🎱
Octal (Base 8)

Used in UNIX/Linux file permissions. Digits 0–7.

🎨
Hexadecimal (Base 16)

Colors in web/apps! #FF5733 is orange. Digits 0–9 & A–F.

📖 Real Life Analogy:

Think of number systems like languages. Humans speak Decimal, computers speak Binary, programmers shorthand with Hex — all saying the same thing in different ways! 🗣️

🏠 Chapter 2 · Decimal Number System (Base 10)

The system you already know! We have 10 fingers, so humans naturally use 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. After 9 we carry over. 🤲

📌 Positional Value — KEY IDEA:

Each digit has a position weight = Baseposition

NumberThousands 10³Hundreds 10²Tens 10¹Units 10⁰Calculation
123412341×1000+2×100+3×10+4×1=1234
30503053×100+0×10+5×1=305

💡 Same logic applies to Binary, Octal, and Hex — just change the base!

💻 Chapter 3 · Binary Number System (Base 2)

Only two digits: 0 and 1. Like a coin — only Heads or Tails! 🪙

🔄 Decimal → Binary

Divide by 2, read remainders BOTTOM to TOP

Convert 13 to Binary:
13 ÷ 2 = 6 rem 1 ← LSB
6 ÷ 2 = 3 rem 0
3 ÷ 2 = 1 rem 1
1 ÷ 2 = 0 rem 1 ← MSB

Read ↑ bottom to top: 1101
🔄 Binary → Decimal

Multiply each bit by 2position, then sum

Convert 1101 to Decimal:
1×2³ = 1×8 = 8
1×2² = 1×4 = 4
0×2¹ = 0×2 = 0
1×2⁰ = 1×1 = 1

8+4+0+1 = 13
📊 Powers of 2 — Memorize These!
Position76543210
2ⁿ1286432168421

🧠 Trick: “1-2-4-8-16-32-64-128” — just double each time going left!

➕ Binary Addition Rules
4 Golden Rules:

0 + 0 = 0 (no carry) 😊
0 + 1 = 1 (no carry) 😊
1 + 0 = 1 (no carry) 😊
1 + 1 = 0, carry 1 🚀
1+1+1 = 1, carry 1 🚀
Example: 1011 + 0110

carry: 1 1 1
    1 0 1 1
+   0 1 1 0
   1 0 0 0 1 = 10001 = decimal 17 ✅
➖ Binary Subtraction Rules
4 Golden Rules:

0 − 0 = 0 😊
1 − 0 = 1 😊
1 − 1 = 0 😊
0 − 1 = 1, borrow 1 from left 😬

Borrow 1 from next column = borrow 2 in value!
Example: 1101 − 0101

   1 1 0 1
−  0 1 0 1
  1 0 0 0 = 1000 = decimal 8 ✅
Verify: 13 − 5 = 8 ✔️
⚡ Pro Tip: Computers subtract using 2’s Complement! A − B = A + (2’s comp of B). Only addition circuits needed! 🧠
⚠️ Common Mistakes in Binary
  • ❌ Forgetting the carry in addition — always check the column to the left!
  • ❌ Reading position from LEFT instead of RIGHT (position 0 is RIGHTMOST)
  • ❌ Confusing MSB (leftmost) with LSB (rightmost)
  • ✅ Write positions 0,1,2,3… from RIGHT to LEFT under each bit

🎱 Chapter 4 · Octal Number System (Base 8)

Uses digits 0 to 7 only. After 7, write 10 (= 8 in decimal). Think of an octopus 🐙 with 8 arms!

📌 Real Use: Linux file permissions! chmod 755 — those numbers are octal!

🔄 Decimal → Octal

Divide by 8, read remainders bottom to top

Convert 100 to Octal:
100 ÷ 8 = 12 rem 4
12 ÷ 8 = 1 rem 4
1 ÷ 8 = 0 rem 1

Read ↑: 144₈
🔄 Octal → Decimal

Multiply each digit by 8position

Convert 144₈ to Decimal:
1×8² = 1×64 = 64
4×8¹ = 4×8 = 32
4×8⁰ = 4×1 = 4

64+32+4 = 100
⚡ Shortcut: Binary ↔ Octal (Group by 3!)

Every Octal digit = exactly 3 binary bits. Group from right!

Binary: 110 101 001 → Octal: 651₈
Octal: 7 5 3 → Binary: 111 101 011
Octal01234567
Binary 000001010011 100101110111

🎨 Chapter 5 · Hexadecimal (Base 16)

Uses 16 symbols: digits 0–9 and letters A–F. A=10, B=11, C=12, D=13, E=14, F=15 🔤

📌 Daily Life: Web colors! #FF5733 = Orange  #1ABC9C = Teal

Dec0123456789101112131415
Hex 0123456789 ABCDEF
Bin 0000000100100011 0100010101100111 1000100110101011 1100110111101111
🔄 Decimal → Hex
Convert 255 to Hex:
255 ÷ 16 = 15 rem F
15 ÷ 16 = 0 rem F

Result: FF₁₆
Max brightness in RGB = FF!
⚡ Binary ↔ Hex Shortcut (Group by 4!)

1 Hex digit = exactly 4 binary bits

Binary: 1010 1111
→ A F → AF₁₆

Hex: 3B
→ 0011 1011 → 00111011₂

🔢 Chapter 6 · BCD — Binary Coded Decimal

BCD encodes each decimal digit separately into 4 bits. Like giving each digit its own little box! 📦

📌 Real Use: Digital clocks ⏰, calculators 🧮, ATM displays 💳

📌 Rule: Each digit 0–9 gets a 4-bit code. Codes 1010–1111 are INVALID in BCD!
Digit0123456789
BCD 00000001001000110100 01010110011110001001
✅ Example: 47 in BCD
Digit 40100
Digit 70111

BCD of 47 = 0100 0111
⚠️ BCD vs Pure Binary!
47 in Pure Binary = 00101111
47 in BCD = 0100 0111

Different! BCD uses more bits but easier for displays!

🔄 Chapter 7 · Gray Code

Only ONE bit changes between consecutive numbers! Prevents errors when multiple bits change. 🎯

📌 Analogy: Like a stove dial 🔥 — smooth, one-step changes. Used in rotary encoders, K-maps!

DecimalBinaryGray CodeBits Changed
0000000
10010011 ✅
20100111 ✅
30110101 ✅
41001101 ✅
51011111 ✅
61101011 ✅
71111001 ✅
🔄 Binary → Gray Code

MSB stays same. Each Gray bit = XOR of current & previous binary bit.

Binary 1011 → Gray:
G₃ = B₃ = 1
G₂ = B₃⊕B₂ = 1⊕0 = 1
G₁ = B₂⊕B₁ = 0⊕1 = 1
G₀ = B₁⊕B₀ = 1⊕1 = 0
Gray = 1110
🔄 Gray → Binary

MSB stays same. Each Binary bit = XOR of previous binary & current gray bit.

Gray 1110 → Binary:
B₃ = G₃ = 1
B₂ = B₃⊕G₂ = 1⊕1 = 0
B₁ = B₂⊕G₁ = 0⊕1 = 1
B₀ = B₁⊕G₀ = 1⊕0 = 1
Binary = 1011

🔁 Chapter 8 · 1’s & 2’s Complement

These are how computers handle negative numbers and perform subtraction! 🧮

1’s Complement

Simply flip every bit! 0→1, 1→0

Number: 00001010 (= 10)
1’s comp: 11110101

⚠️ Problem: Two zeros!
00000000 = +0
11111111 = −0 (awkward!)
🧠 Like a photo negative — dark becomes light! 📷
2’s Complement ⭐ (Modern Standard)

Step 1: Find 1’s complement  Step 2: Add 1

+10 = 00001010
1’s comp = 11110101
Add 1 →
−10 = 11110110
✅ Only ONE zero. Used in ALL modern computers!
💡 Why 2’s Complement is Brilliant!

Subtraction becomes addition: 5 − 3 = 5 + (−3)

+5 = 00000101
−3 = 11111101 (2’s comp of 3)
 = 1 00000010 → drop overflow → 00000010 = +2 ✅

➕➖ Chapter 9 · Signed & Unsigned Numbers

🏏 Unsigned Numbers

Like a Cricket Score — can never be negative! All bits used for value.

  • Only 0 and above
  • 8-bit range: 0 to 255
  • 16-bit range: 0 to 65535
  • n-bit: 0 to 2ⁿ−1
11111111₂ = 255 (max 8-bit)
00000000₂ = 0 (min)

📌 Used for: pixel colors, memory addresses, age

🏦 Signed Numbers

Like a Bank Balance — can go negative! MSB is the sign bit.

  • MSB = 0 → Positive ✅
  • MSB = 1 → Negative ❌
  • 8-bit range: −128 to +127
  • n-bit: −2ⁿ⁻¹ to 2ⁿ⁻¹−1
01111111₂ = +127 (max)
10000000₂ = −128 (min)

📌 Used for: temperature, bank balance, scores

📊 Master Comparison Table
FeatureUnsignedSigned SM1’s Comp2’s Comp ⭐
Negatives?
Max 8-bit+255+127+127+127
Min 8-bit0−127−127−128
ZerosOneTwoTwoOne ⭐
Used inCountersOldSome HWAll CPUs!
🌡️ Real Life: Temperature!

Delhi summer ☀️ = +45°C → positive, MSB=0
Ladakh winter ❄️ = −20°C → negative, MSB=1 (2’s complement)

The sign bit tells the computer: warm day or freezing cold! 😄

💥 Chapter 10 · Overflow!

Overflow = result too large for the bit count. Like pouring 300mL into a 250mL cup — it spills! ☕

Unsigned Overflow
11111111 (255)
+ 00000001 ( 1)
= 100000000 → only 8 bits kept = 00000000 (0) ❌
Wrapped around to 0!
Signed Overflow
01111111 (+127)
+ 00000001 ( +1)
= 10000000 (−128) ❌ +127+1 should be +128
but MSB flipped → looks negative!
✅ Overflow Detection:

If carry INTO MSB ≠ carry OUT OF MSB → Overflow occurred! 🚨

📊 Chapter 11 · Master Reference Table (0–15)

All systems at a glance — bookmark this! 🔖

DecBinaryOctalHexBCDGray
000000000000000
100011100010001
200102200100011
300113300110010
401004401000110
501015501010111
601106601100101
701117701110100
8100010810001100
9100111910011101
10101012A1111
11101113B1110
12110014C1010
13110115D1011
14111016E1001
15111117F1000

⚠️ Red rows (10–15): Invalid in BCD — BCD only covers digits 0–9!

🧠 Chapter 12 · Tricks, Tips & Common Mistakes

🏆 Memory Tricks
  • 🔢 Powers of 2: “1-2-4-8-16-32-64-128” — double each time!
  • 🎱 Octal = Octopus = 8 arms = 8 digits (0–7)
  • 🎨 Hex colors: R,G,B each = 2 hex digits (00–FF)
  • 🔄 Binary ↔ Octal: group by 3 bits
  • 🔄 Binary ↔ Hex: group by 4 bits
  • 📝 2’s complement: “flip then add 1”
  • 📌 MSB = leftmost = Most Significant (or sign bit)
  • 📌 LSB = rightmost = Least Significant
⚠️ Common Mistakes
  • ❌ Mixing up BCD and pure binary
  • ❌ Forgetting BCD codes 1010–1111 are INVALID
  • ❌ Reading binary position LEFT to RIGHT (0 is RIGHTMOST!)
  • ❌ Forgetting carry in binary addition
  • ❌ Confusing 1’s complement with 2’s complement
  • ❌ Not adding leading zeros before grouping bits
  • ❌ Treating a 2’s complement negative as positive
  • ❌ Ignoring overflow when adding same-sign numbers
⚡ Quick Conversion Cheatsheet
ConvertMethodShortcut?
Dec → BinaryDivide by 2, remainders ↑None
Binary → DecSum of bit × 2ⁿNone
Binary → OctalGroup 3 bits from right⚡ YES
Octal → BinaryEach digit → 3 bits⚡ YES
Binary → HexGroup 4 bits from right⚡ YES
Hex → BinaryEach digit → 4 bits⚡ YES
Dec → BCDEach decimal digit → 4-bit⚡ YES
Binary → GrayMSB same; XOR each with prevFormula
Dec → 2’s CompConvert → flip → add 1Or: flip after first 1 from right
⚡ Ultra-Fast 2’s Complement Trick!

From RIGHT: keep all bits up to and including the first 1, then flip all remaining bits!

Number: 0 1 0 1 1 0 1 0 0
Keep →→→→→→ 1 0 0 (first 1 + trailing zeros)
Flip rest: 1 0 1 0 0 1 1 0 0
Result: 101001100 ✅ Faster than flip+add1!

🌍 Chapter 13 · Real World Applications

🎨
Web Colors

#FF5733 → Red=FF(255), Green=57(87), Blue=33(51). Every web color = 3 hex bytes!

Digital Clocks

12:35 stored as BCD: 0001 0010 : 0011 0101. Each digit = 4-bit code!

💾
File Sizes

1 KB = 2¹⁰ = 1024 bytes. 1 GB = 2³⁰. Always powers of 2!

🔐
IP Addresses

192.168.1.1 — each part is an 8-bit unsigned number. Max is 255!

🌡️
Temperature Sensors

−20°C stored using signed 8-bit (2’s complement). Negative = MSB is 1!

🖥️
Memory Addresses

RAM shown as 0xFFFF — hex is compact vs 1111111111111111 binary!

✏️ Quick Practice Problems

🔢 Convert These:
  1. 42₁₀ → Binary = ____?
  2. 11001₂ → Decimal = ____?
  3. 75₁₀ → Octal = ____?
  4. 1011 0101₂ → Hex = ____?
  5. 39₁₀ → BCD = ____?
  6. 1010₂ → Gray Code = ____?
  7. 2’s comp of 00010011 = ____?
✅ Answers:
  1. 101010
  2. 25
  3. 113₈
  4. B5₁₆
  5. 0011 1001
  6. 1111
  7. 11101101
🎓 DLD NUMBER SYSTEMS — COMPLETE GUIDE
Binary · Octal · Hex · BCD · Gray Code · Signed · Unsigned · 1’s & 2’s Complement
📖 Study Hard 💡 Practice Daily 🧠 Understand, Don’t Memorize 🏆 You’ve Got This!
Digital Logic Design Study Guide · All 13 Chapters

🧮 The Complete Number Systems Encyclopedia

From Zero to Hero: Binary, Hex, Signed Math, and Digital Codes

📍 Topic: Digital Logic 📍 Level: Beginner to Advanced 📍 Status: Master Guide

🌟 1. Introduction: Why Bases?

Computers are like a row of light switches—either ON (1) or OFF (0). This is why we use Base-2.

  • Base-10 (Decimal): 0-9 (Our fingers! 🖐️)
  • Base-2 (Binary): 0, 1 (The PC’s soul 💻)
  • Base-8 (Octal): 0-7 (Shorthand for 3 bits)
  • Base-16 (Hex): 0-F (Shorthand for 4 bits – used in Color Codes like #FFFFFF!)

🔄 2. Conversion Secrets

Type Method
Dec ➡️ Any Divide & Conquer: Divide by base, track remainders bottom-up.
Any ➡️ Dec Weight Lifting: Multiply digits by $Base^{position}$.
Bin ➡️ Hex The “4-Pack”: Group bits by 4. Use 8-4-2-1 rule.
Oct ➡️ Bin The “Trio”: Each Octal digit becomes 3 bits.

➕ 3. Binary Math Rules

Add (+)
0+0 = 0
0+1 = 1
1+1 = 10
1+1+1 = 11
Sub (-)
0-0 = 0
1-0 = 1
1-1 = 0
10-1 = 1 (Borrow)

💡 Trick: In subtraction, if you borrow, the ‘0’ becomes ‘2’ (in decimal thinking) because $Base=2$.

⚖️ 4. Signed Numbers (Negatives)

MSB (Leftmost bit) is the Boss: 0 = Positive (+), 1 = Negative (-).

Example: Represent -5 in 8-bit
1. Positive 5: 00000101
2. 1’s Comp (Flip): 11111010
3. 2’s Comp (Add 1): 11111011

🔡 5. Specialized Codes

• BCD (Binary Coded Decimal): For digital clocks! ⏰ Each digit gets 4 bits.
Ex: 25 ➡️ 0010 0101.

• Gray Code: The “Unit Distance” code. Only 1 bit flips at a time. Used to prevent glitches in sensors! 🛰️

• Excess-3: BCD + 0011 (3). Helps in subtraction.

🛑 Avoid These Traps!

  • Mistake: Thinking 1010 is BCD for “10”.
    Fact: BCD only goes up to 9 (1001). 10 is 0001 0000.
  • Mistake: Forgetting to carry in Binary Addition.
  • Mistake: Using 2’s Comp on positive numbers.
    Fact: 2’s Complement is only for NEGATIVE representation.

📊 Decimal to Binary/Hex/Octal Quick Map

Decimal Binary (4-bit) Octal Hexadecimal BCD
00000000000
50101550101
910011191001
10101012A0001 0000
15111117F0001 0101

💡 Remember: Computers aren’t smart, they’re just fast! Master the numbers, master the machine. 💻✨

DLD Comprehensive Series | Part 01: Number Systems

1$!)

📊 The Master Cheat Sheet (0-15)

This table covers everything you will ever need.

Decimal (Base 10)Binary (Base 2)Octal (Base 8)Hexadecimal (Base 16)
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

🧠 How to Remember (Without Memorizing!)

You only need to remember two magic codes:

1. The “4-2-1” Trick (For Octal) 🐙

Octal digits go from 0 to 7. Notice that $4+2+1 = 7$.

This is all you need to find any Octal number.

  • Question: What is 4 in Octal?
    • Look at your code: 4 – 2 – 1
    • Do you need the “4”? YES (Put a 1)
    • Do you need the “2”? NO (Put a 0)
    • Do you need the “1”? NO (Put a 0)
    • Result: 100 in binary is 4 in Octal.
  • Question: What is 6 in Octal?
    • How do you make 6? You need 4 + 2.
    • 4 (Yes) – 2 (Yes) – 1 (No)
    • Result: 110

2. The “8-4-2-1” Trick (For Hexadecimal) 🔶

Hex goes up to 15. Notice that $8+4+2+1 = 15$.

This is the code for Hex.

  • Question: What is C (12) in Binary?
    • How do you make 12? 8 + 4.
    • 8 (Yes) – 4 (Yes) – 2 (No) – 1 (No)
    • Result: 1100
  • Question: What is F (15) in Binary?
    • How do you make 15? 8 + 4 + 2 + 1.
    • Result: 1111 (All switches ON!)

✍️ Exam Hack: Build the Table in 10 Seconds

If you sit in an exam, draw this immediately on rough paper. You don’t need to calculate anything. Just follow this pattern:

  1. Column 1 (The “1s” place): Alternating 0, 1, 0, 1, 0, 1...
  2. Column 2 (The “2s” place): Alternating 00, 11, 00, 11...
  3. Column 3 (The “4s” place): Alternating 0000, 1111...
  4. Column 4 (The “8s” place): Alternating 00000000, 11111111...

Try it:

Write 0-1-0-1 down the page.

Next to it, write 00-11-00-11.

Next to that, 0000-1111.

Boom! You just wrote the entire binary table without doing a single math calculation. 😎

🛑 Common Confusion Check

User asked: “What is 4 equivalent in octal?”

  • In Decimal: It is 4.
  • In Octal: It is also 4.
  • In Hex: It is also 4.

Why? Because all number systems are the SAME until you run out of digits!

  • Binary runs out at 1 (so 2 becomes 10).
  • Octal runs out at 7 (so 8 becomes 10).
  • Decimal runs out at 9 (so 10 becomes 10).
  • Hex runs out at F (so 16 becomes 10).

So, 0, 1, 2, 3, 4, 5, 6, 7 are the identical in Octal, Decimal, and Hex! The confusion only starts at number 8.

Hi ! Think of me as your study partner. I know Digital Logic Design (DLD) can feel like a maze of 1s and 0s, but let’s break down Signed and Unsigned numbers as if we’re talking about a simple bank ledger or a cricket score.

Here is a simplified guide you can copy and paste into your notes.


🔢 Understanding Signed vs. Unsigned Numbers

In the world of computers, everything is stored in “boxes” called bits. Usually, we use 8 bits (1 Byte) to represent a number.

1. Unsigned Numbers (The “Positive Only” Club)

Unsigned numbers are like a tape measure. They start at zero and only go up. There is no concept of “negative” here.

  • Rule: All bits are used to represent the value of the number.
  • Range (for 8 bits): $0$ to $2^8 – 1$ (which is 0 to 255).
  • Example: * Binary 00001010 = Decimal 10
    • Binary 11111111 = Decimal 255

Real-life Application: Think of your Age or the Number of runs a batsman scores. You can’t have -20 runs or be -5 years old!


2. Signed Numbers (The “Plus and Minus” Club)

Signed numbers are like a Bank Statement. You can have money in the bank (Positive), or you can be in debt (Negative).

To show if a number is positive or negative, we reserve the left-most bit (the Most Significant Bit or MSB) as a “Sign Post.”

  • The Sign Bit Rule:
    • If the first bit is 0 $\rightarrow$ The number is Positive (+).
    • If the first bit is 1 $\rightarrow$ The number is Negative (-).

How do we write Negative numbers?

In DLD, we don’t just put a minus sign. We use 2’s Complement.

  1. Start with the positive binary.
  2. Flip all bits (0 becomes 1, 1 becomes 0).
  3. Add 1 to the result.
  • Example (using 8 bits):
    • +5 is 00000101 (Starts with 0)
    • -5 is 11111011 (Starts with 1)

Real-life Application: Temperature. It can be $+40^\circ\text{C}$ in Delhi or $-10^\circ\text{C}$ in Leh. We need a sign bit to tell the difference!


📊 Quick Comparison Table

FeatureUnsigned NumbersSigned Numbers
Range (8-bit)0 to 255-128 to +127
Sign BitNo (All bits are value)Yes (Left-most bit)
Negatives?Not possiblePossible
Best ForCounting items, Memory addressesCalculations, Temperature, Finance

💡 A Simple Way to Remember

  • Unsigned: Think of a Whole Number ($0, 1, 2, 3…$). It’s simple and straightforward.
  • Signed: Think of a Direction. If you walk forward, it’s (+). If you walk backward, it’s (-). The first bit is just a “direction arrow.”

🧠 Check your understanding:

If you see the binary number 10000010:

  • In Unsigned, it is a large positive number (130).
  • In Signed, it is a Negative number because it starts with 1.

Signed & Unsigned Numbers

Student Name: ________________
Digital Logic Design (DLD)
1. Unsigned Numbers (Positives Only)

Think of it like a Cricket Score. You can’t have -50 runs!

• Rule: All 8 bits are used for the value.
• Range: 0 to 255 ($0$ to $2^n – 1$).
• Binary Example: 11111111 = 255

2. The Concept of “Bits”

In a standard 8-bit system:
• MSB: The leftmost bit (The “Sign Post”).
• LSB: The rightmost bit (The Smallest value).
• Storage: Computers use fixed boxes. If a number is too big, it “overflows.”

Real-World Apps
  • Counting People (Unsigned)
  • Bank Balance (Signed)
  • Digital Thermometers (Signed)
  • Memory Addresses (Unsigned)
3. Signed Numbers (+ and -)

The Left-Most Bit (MSB) tells us the Sign:

• If MSB is 0: The number is Positive (+)
• If MSB is 1: The number is Negative (-)
• Range: -128 to +127.

4. How to make a Negative?

Using “2’s Complement” Method:
1. Start: Write positive binary (e.g., 5 is 00000101).
2. Flip: Change 0s to 1s and 1s to 0s (11111010).
3. Add 1: Result is 11111011 (-5).

Quick Summary Table
Feature Unsigned Signed
Negatives? No Yes
Max (8-bit) 255 +127
DLD Study Guide | Page 1 of 1

// — DLD CHAPTER: 2’S COMPLEMENT MASTERY — let dld_advanced_pg = `

🔢 2’s Complement Deep Dive

Hey ${name}! Let’s master the math of the CPU. 2’s Complement is the industry standard because it makes addition and subtraction identical!

🛠️ The 3-Step Success Formula

To convert a positive number (X) to its negative counterpart (-X):

1. Binary: Write the magnitude in 8 bits.
2. Flip: Change all 0s to 1s and 1s to 0s (1’s Comp).
3. Add 1: Add binary 1 to the LSB.
Tip: The MSB (leftmost bit) is your sign! 1 = Negative.

❓ Core Quiz (Part 1)
Q1: Why use 2’s complement over 1’s?
A: It eliminates “Negative Zero” and simplifies hardware adder circuits.

Q2: Range of 8-bit signed?
A: -128 to +127.

Q3: What is 0000 0000 in 2’s Comp?
A: Still 0. Adding 1 to 1111 1111 causes a carry-out that is ignored.

Q4: Convert -1 to binary (8-bit).
A: 1111 1111.

Q5: Is 1000 0000 positive?
A: No, it’s the “weird” case: -128.
🧪 Practice Lab (Q6-Q10)
Q6: Convert +13 to 2’s Comp.
A: 0000 1101 (Positives don’t change!)
Q7: Convert -5 to 2’s Comp.
A: 00000101 → 11111010 + 1 = 1111 1011
Q8: What is 1111 1110 in decimal?
A: Flip & add 1 back → 00000001 + 1 = 2. So, -2.
Q9: What happens during Overflow?
A: Two positives add to make a negative (or vice versa).
Q10: Calculate 5 – 3 using 2’s Comp.
A: 5 + (-3) → 0101 + 1101 = (1)0010 = 2.
🚀 Pro Shortcut: The “Right-to-Left” Trick

Scan bits from Right to Left. Keep everything the same until you hit the first ‘1’. Keep that ‘1’, then flip everything to the left of it!

Example: -4
4 is 0000 0100.
First ‘1’ is at 2^2. Keep ‘100’, flip rest: 1111 1100.
Keep Practicing ${name}! Bit-shifting to success! 🚀
`;

⚡ Flashback Revision: The “Sign” Problem

  • Computers only know 0 and 1. They don’t have a “+” or “-” key.
  • So, we steal the first bit (MSB) to act as the sign.
  • 0 = Positive (+) 😄
  • 1 = Negative (-) 😠
FeatureUnsigned NumbersSigned Numbers
MeaningOnly positive numbers (magnitude only).Can be Positive (+) or Negative (-).
The MSB (First Bit)It is part of the value (e.g., 128).It is the Sign Bit (0 is +, 1 is -).
Range (for 8 bits)0 to 255 (Huge positive range).-128 to +127 (Split range).
Example (1111)$8+4+2+1 = \mathbf{15}$In Signed 2’s comp, this is -1.
Use CaseCounting apples, memory addresses.Temperature, Bank balance (debt).


Q1(a) Represent the decimal number 232 in Binary, Gray Code, Octal, BCD, and Excess-3.

1. Decimal to Binary

Target Number: 232

We find the powers of 2 that add up to 232:

  • 128 + 64 + 32 + 8 = 232

So, we place a “1” at those positions and “0” at the others:

Binary Answer: 1110 1000


2. Binary to Gray Code

Rule: Copy the first bit, then XOR (add without carry) the neighbors.

Binary: 1110 1000

  • 1 (Copy first) -> 1
  • 1 + 1 = 0
  • 1 + 1 = 0
  • 1 + 0 = 1
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 0 + 0 = 0
  • 0 + 0 = 0

Gray Code Answer: 1001 1100


3. Binary to Octal

Rule: Group binary bits in sets of 3 starting from the right.

Binary: 011 | 101 | 000

  • 011 = 3
  • 101 = 5
  • 000 = 0

Octal Answer: 350 (Base 8)


4. Decimal to BCD (Binary Coded Decimal)

Rule: Convert each decimal digit separately into 4-bit binary.

Digits: 2 | 3 | 2

  • 2 = 0010
  • 3 = 0011
  • 2 = 0010

BCD Answer: 0010 0011 0010


5. Decimal to Excess-3

Rule: Add 3 to each decimal digit, then convert to binary.

Digits: 2 | 3 | 2

  • First Digit (2): 2 + 3 = 5 -> 0101
  • Second Digit (3): 3 + 3 = 6 -> 0110
  • Third Digit (2): 2 + 3 = 5 -> 0101

Excess-3 Answer: 0101 0110 0101


Q1(b) Difference between Signed and Unsigned Binary Numbers

Unsigned Numbers:

  • Definition: These numbers can only be positive.
  • MSB (Most Significant Bit): The first bit is used for the value (magnitude), just like any other bit.
  • Range: Stores larger positive numbers (e.g., 0 to 255).
  • Example: 1111 1111 = 255.

Signed Numbers:

  • Definition: These numbers can be positive or negative.
  • MSB (Most Significant Bit): The first bit is the “Sign Bit”.
    • 0 means Positive (+)
    • 1 means Negative (-)
  • Range: The range is split between positive and negative (e.g., -128 to +127).
  • Example: 1111 1111 usually represents -1 in Two’s Complement.

Q1(c) How to perform Addition and Subtraction using 2’s Complement

1. Addition

Addition in 2’s complement is straightforward. You simply add the two binary numbers together. If there is a carry out of the final bit, it is discarded.

Example: 5 + 2

0101 (5)

  • 0010 (2)

0111 (Answer is 7)

2. Subtraction

Computers perform subtraction (A – B) by adding the negative version of the second number (A + (-B)).

Step 1: Find the 2’s Complement of the number to be subtracted (B).

  • Example: 7 – 5
  • Binary for 5 is 0101.
  • Invert digits (1s Complement): 1010
  • Add 1: 1011 (This is -5)

Step 2: Add the first number (A) to the 2’s Complement of B.

0111 (7)

  • 1011 (-5)

10010

Step 3: Discard the final carry.

Since we are working with 4 bits, we ignore the extra ‘1’ on the far left.

Final Result: 0010 (Which is equal to decimal 2)

© The Life Navigator ( for PSYFISKILLs EDUVERSE PVT. LTD.) – 2023-2025