← Computer Science notes

Unit 1 Β· Digital Electronics & Computer Architecture

Chapter 1 Β· Number Systems & Codes

pdcampus.in
pdcampus.in β€’ DSSSB TGT CS
Beginner Topper
Number Systems & Codes - 4 Types + 5 Codes Unit 1 β€’ Ch 1 β€’ DSSSB asks 3-4 Q every year β€’ Complete Story
Beginner Story Mode Complete Notes

Let me tell you a small story first. Imagine early humans. They had 10 fingers, so they started counting 0-9 and after 9 they said "one zero" β†’ 10. That's why we use Decimal.

Now think of your room's light switch. It has only two states β€” ON (1) and OFF (0). A computer is made of crores of such tiny switches (transistors). So computer can only understand 0 and 1. That's Binary.

But writing 11010101 for every number is long, right? So programmers invented shortcuts β€” group 3 binary bits = Octal, group 4 bits = Hexadecimal. Same number, different dress.

Number Systems 4 Types handwritten
Fig 1: Same quantity, 4 different languages - 10 fingers = Decimal, Bulb ON/OFF = Binary
1. Decimal - Our Daily Language

Base = 10, digits 0-9. Each position has weight 10^position.
Example: 13 = 1Γ—10ΒΉ + 3Γ—10⁰ = 10+3.
You already know this, but this weight idea is key for all other systems. In binary, weight is 2^position.

2. Binary - Computer's Mother Tongue

Base = 2, only 0 and 1.
Why? Inside CPU, voltage High = 1, Low = 0. Like asking "light is on?" β€” answer only Yes/No.
Daily example: Imagine you have 13 toffees. You make pairs. Leftover is remainder. You keep making pairs of pairs. That's exactly decimal β†’ binary division method.

3. Conversion - The Heart of Chapter (Full Detail)

A) Binary β†’ Decimal - Weight Method (Easiest)
Write weights from right: 1,2,4,8,16,32... Multiply where bit is 1 and add.

1101β‚‚ = (1Γ—8) + (1Γ—4) + (0Γ—2) + (1Γ—1) = 8+4+0+1 = 13
That's 13 toffees! 8+4+1 boxes.
Binary conversion weight and division method handwritten
Fig 2: Weight Method + Division Method - MSB leftmost, LSB rightmost - Read remainders Bottom→Top

B) Decimal β†’ Binary - Divide by 2 Method
Divide number by 2, note remainder. Continue dividing quotient. Read remainders from bottom to top.

13 Γ·2 =6 rem 1 (LSB - Least Significant Bit)
6 Γ·2 =3 rem 0
3 Γ·2 =1 rem 1
1 Γ·2 =0 rem 1 (MSB - Most Significant Bit)
Bottom to top = 1101
Formula: Decimal = Ξ£ (bit Γ— 2ⁿ) where n = position from right (0,1,2...)

C) Binary ↔ Octal (Group of 3)
Why 3? Because 2Β³=8. So 1 octal digit = 3 binary bits. Group binary from right in 3s.
Example: 110101β‚‚ β†’ group 110 101 β†’ 6 5 β†’ 65β‚ˆ. Super useful in Unix file permissions: 777 = 111 111 111.

D) Binary ↔ Hex (Group of 4)
Why 4? 2⁴=16. 1 hex digit = 4 bits. Hex digits: 0-9, A=10, B=11, C=12, D=13, E=14, F=15.
Example: 1101 1110β‚‚ β†’ D E β†’ DE₁₆ = 222₁₀. You see this in colors: #FF5733, memory addresses like 0x1A2F. DSSSB loves this conversion.

Quick Table you must mug:
1010β‚‚ = 12β‚ˆ = 10₁₀ = A₁₆
1111β‚‚ = 17β‚ˆ = 15₁₀ = F₁₆

E) Fractional Binary - Bonus for DSSSB (Beginners miss this)
After decimal point, weights become 1/2, 1/4, 1/8...
Example: 0.101β‚‚ = 1Γ—1/2 +0Γ—1/4 +1Γ—1/8 = 0.5+0.125=0.625. To convert decimal fraction to binary, multiply by 2 and take integer part.

4. How Computer Does Subtraction? - Complements

Here is a secret: Computer does not know subtraction. It only knows addition.
So A - B = A + (-B). But how to store -B?

1's Complement: Just flip bits. 0β†’1, 1β†’0. Like photo negative. 0101 β†’ 1010.
2's Complement: 1's complement +1. This is what computers actually use to store negative numbers. 0101 (5) β†’ 1010 β†’ 1011 = -5.
Story: Imagine you owe β‚Ή5. Instead of writing -5, you write "I will pay 5 less next time". Computer stores -5 as 1011 so that when you add, it automatically subtracts.

Complements 1s 2s handwritten explanation
Fig 3: 2's Complement = Flip +1 - Why Single Zero? No -0 confusion!
Range in n-bit 2's complement: -2^(n-1) to 2^(n-1)-1. For 4-bit: -8 to +7
DSSSB Trap: 1's complement has two zeros: +0=0000, -0=1111 (waste). 2's complement has single zero: 0000. That's why computers use 2's.

Subtraction Example - Must understand:
5-2 = 5 + (-2)
5 = 0101
2 = 0010 β†’ 1's =1101 β†’ 2's=1110 = -2
Add: 0101 +1110 =10011 β†’ discard extra carry 1 β†’ 0011 =3 βœ”οΈ Correct!
If final carry 1 β†’ result positive. If no carry β†’ result negative, take 2's complement again.

5. Computer Codes - Alphabets of Computer

BCD (Binary Coded Decimal):
Calculator and digital clocks don't store 13 as 1101. They store each digit separately in 4 bits. 13 β†’ 0001 0011 (1=0001, 3=0011). That's BCD. Range 0-9 valid, 1010-1111 invalid. Called 8421 code (weights).

Excess-3: BCD +3. Why add 3? To make subtraction and 9's complement easy. Self-complementing code. Example: 0 β†’ 0011 (0+3). 13 in Excess-3 = (1+3)=4β†’0100, (3+3)=6β†’0110 β†’ 0100 0110.

ASCII - DSSSB's Favorite (American Standard Code):
Computer stores 'A' as 65. That's ASCII. Originally 7-bit (0-127), now extended 8-bit (0-255).
You must remember: A-Z =65-90, a-z=97-122, 0-9=48-57, Space=32, Enter=13.
Trick: 'A' +32 = 'a' (65+32=97). So to convert capital to small, add 32 in programming.

EBCDIC:
Old IBM mainframe code, 8-bit, 256 chars. A=11000001. Not used much now, but DSSSB may ask difference from ASCII. Remember: ASCII is 7-bit standard, EBCDIC is 8-bit IBM.

Gray Code - Only 1 Bit Changes:
Normal binary 01β†’10 changes 2 bits at once (0β†’1 and 1β†’0). If wires read at slightly different time, you get wrong value. Gray code changes only 1 bit between successive numbers: 00β†’01β†’11β†’10β†’00. Used in your AC knob (rotary encoder), robotics, K-map to reduce errors.
Formula: Gray = Binary XOR (Binary>>1)

BCD ASCII Gray Code handwritten notes
Fig 4: BCD per digit, ASCII A=65 a=97, Gray only 1-bit change - safe for sensors like AC knob
6. Common Mistakes & DSSSB PYQ Style
  • Q: 2's complement of 0000? β†’ 0000 (only one zero)
  • Q: Excess-3 of decimal 2? β†’ 2+3=5 β†’ 0101
  • Q: Octal of 110101? β†’ 110 101 = 65β‚ˆ
  • Q: How many bits to represent 0-15? β†’ 4 bits (2^4=16)
  • Q: ASCII of 'B' is 66, what is 'b'? β†’ 98 (66+32)
  • Q: BCD addition correction? β†’ If sum >9 or carry, add 6 (0110)
Key: HEX is shorthand for binary in coding! 1 HEX = 4 binary bits

Final Story Recap: You started with 10 fingers β†’ Decimal. You saw bulb ON/OFF β†’ Binary. You grouped 3 bulbs β†’ Octal, 4 bulbs β†’ Hex for short writing. You learned computer can't do minus, so it flips bits (1's) and adds 1 (2's). And you learned how it writes A as 65 (ASCII) and makes safe sensors with Gray code. If you understood this story, you don't need any other book for this chapter. Practice 20 conversions and you're done for DSSSB.

Topper Revision 1 Page = Full Chapter
SystemBaseDigitsBits
Binary20,11
Octal80-73
Dec100-9-
Hex160-9,A-F4
Dβ†’B: Γ·2 reverse rem | Bβ†’D: Ξ£ bitΓ—2^pos | B↔O: 3 bits | B↔H: 4 bits
1's = invert | 2's =1's+1 | Range n-bit 2's: [-2^(n-1), 2^(n-1)-1]

Codes:

  • BCD: 4-bit per digit, 0000-1001 valid, 8421 weighted, 12=0001 0010, add 6 correction if >9
  • Excess-3: BCD+3, self-complementing, 0β†’0011, 9β†’1100
  • ASCII: 7-bit std 0-127, 8-bit ext 0-255, A=65, a=97, 0=48, Space=32, diff A-a=32
  • EBCDIC: 8-bit IBM 256 chars, legacy
  • Gray: 1-bit change, G=B xor (B>>1), use: encoders, K-map, error reduction, cyclic
Subtraction: A-B = A + 2's(B), discard end carry. No carry β†’ negative, 2's of result

Must Remember:
β€’ 1's dual zero, 2's single zero β†’ 2's used
β€’ Bits for N numbers = ceil(log2 N)
β€’ Hex β†’ Binary expand each hex to 4 bits
β€’ (1A)16 = 0001 1010β‚‚ = 032β‚ˆ
β€’ Fractional: 0.101β‚‚=0.625₁₀

1010β‚‚=12β‚ˆ=10₁₀=A₁₆ | 1111β‚‚=17β‚ˆ=15₁₀=F₁₆ | 1101β‚‚=15β‚ˆ=13₁₀=D₁₆

PYQ Pattern - DSSSB

β€’ 2's complement of 1001β‚‚ β†’ 0111
β€’ Excess-3 of 2 β†’ 0101
β€’ ASCII bits β†’ 7 std, 8 ext
β€’ Octal of 110101β‚‚ β†’ 65β‚ˆ
β€’ BCD of 13 β†’ 0001 0011

© 2026 pdcampus.in · All rights reserved. · Made with ❀️ for Indian students.