Unit 1 Β· Digital Electronics & Computer Architecture
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.
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.
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.
A) Binary β Decimal - Weight Method (Easiest)
Write weights from right: 1,2,4,8,16,32... Multiply where bit is 1 and add.
B) Decimal β Binary - Divide by 2 Method
Divide number by 2, note remainder. Continue dividing quotient. Read remainders from bottom to top.
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.
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.
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.
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.
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)
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.
| System | Base | Digits | Bits |
|---|---|---|---|
| Binary | 2 | 0,1 | 1 |
| Octal | 8 | 0-7 | 3 |
| Dec | 10 | 0-9 | - |
| Hex | 16 | 0-9,A-F | 4 |
Codes:
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ββ
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