Number Systems
Hi students! š Welcome to our exciting journey into the world of number systems in electronics! In this lesson, you'll discover how computers and digital devices actually "think" using different number systems. We'll explore binary (the language of computers), hexadecimal (a programmer's best friend), and how they relate to our familiar decimal system. By the end of this lesson, you'll understand why digital electronics relies on these systems and how to convert between them like a pro! š
Understanding Different Number Systems
Let's start with something familiar, students. Every day, you use the decimal system (also called denary) without even thinking about it! When you count 1, 2, 3... up to 10, you're using base 10. This means we have 10 different digits (0-9) before we need to "carry over" to the next position.
But here's the fascinating part - computers can't actually understand decimal numbers directly! š¤ Digital electronics work with electricity, and electricity has two main states: ON and OFF. This is where binary comes in - it's a base 2 system using only two digits: 0 (OFF) and 1 (ON).
Think of it like a light switch in your room. It's either ON or OFF - there's no "halfway" position that's reliable in digital electronics. This simple concept powers everything from your smartphone to NASA's space computers!
Hexadecimal (base 16) might seem strange at first, but it's incredibly useful in electronics. It uses 16 symbols: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Why 16? Because it perfectly represents groups of 4 binary digits, making it much easier for humans to read and write long binary numbers.
Binary: The Language of Digital Electronics
students, imagine you're trying to communicate using only a flashlight that can be ON or OFF. That's essentially how binary works! In binary, each position represents a power of 2, starting from $2^0$ on the right.
Let's look at the binary number 1011:
- Position 1 (rightmost): $1 \times 2^0 = 1 \times 1 = 1$
- Position 2: $1 \times 2^1 = 1 \times 2 = 2$
- Position 3: $0 \times 2^2 = 0 \times 4 = 0$
- Position 4: $1 \times 2^3 = 1 \times 8 = 8$
Adding these up: $8 + 0 + 2 + 1 = 11$ in decimal!
Here's a fun fact: The word "bit" comes from "binary digit" - each 1 or 0 is one bit. Eight bits make a byte, which can represent 256 different values (from 00000000 to 11111111). That's why computer memory is often measured in bytes! š¾
In real-world electronics, binary is everywhere. When you press a key on your keyboard, it sends a unique binary code. The letter 'A' is represented as 01000001 in ASCII code. Your digital camera stores each pixel's color information in binary, and even this text you're reading right now is stored as binary data!
Hexadecimal: Making Binary Human-Friendly
students, imagine trying to remember this binary number: 11010110101011110010. Pretty difficult, right? šµ That's where hexadecimal saves the day! This same number in hex is D6AF2 - much easier to handle!
Hexadecimal uses these symbols:
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (same as decimal)
- A=10, B=11, C=12, D=13, E=14, F=15
Each hex digit represents exactly 4 binary digits (bits). This makes conversion super convenient:
$- Binary 0000 = Hex 0$
$- Binary 0001 = Hex 1$
$- Binary 1010 = Hex A$
$- Binary 1111 = Hex F$
In electronics, you'll see hex everywhere! Memory addresses in computers are written in hex (like 0x2A4F), color codes in web design use hex (#FF0000 for red), and when debugging electronic circuits, engineers often use hex to represent data more compactly.
Here's a cool example: The Game Boy's famous startup sound is stored as hex values that represent different musical notes. Each hex number corresponds to a specific frequency that creates those nostalgic beeps! š®
Converting Between Number Systems
Let's master the art of conversion, students! These skills are essential for anyone working with digital electronics.
Decimal to Binary:
To convert decimal 25 to binary, we repeatedly divide by 2 and track remainders:
- 25 Ć· 2 = 12 remainder 1
- 12 Ć· 2 = 6 remainder 0
- 6 Ć· 2 = 3 remainder 0
- 3 Ć· 2 = 1 remainder 1
- 1 Ć· 2 = 0 remainder 1
Reading remainders from bottom to top: 25 decimal = 11001 binary!
Binary to Hexadecimal:
Group binary digits in sets of 4 (from right to left), then convert each group:
Binary 11010110 becomes:
$- 1101 = D in hex$
$- 0110 = 6 in hex$
- Result: D6 in hex
Hexadecimal to Decimal:
For hex 2A3, multiply each digit by the appropriate power of 16:
$2 \times 16^2 + 10 \times 16^1 + 3 \times 16^0 = 2 \times 256 + 10 \times 16 + 3 \times 1 = 512 + 160 + 3 = 675$
Two's Complement: Representing Negative Numbers
students, you might wonder: "How do computers represent negative numbers using only 1s and 0s?" The answer is two's complement - a clever system used in virtually all modern digital devices! š§
In two's complement, we use the leftmost bit as a sign bit. For an 8-bit number:
- If the leftmost bit is 0, the number is positive
- If the leftmost bit is 1, the number is negative
To find the two's complement of a number:
- Write the positive number in binary
- Invert all bits (0 becomes 1, 1 becomes 0)
- Add 1 to the result
Let's find -5 in 8-bit two's complement:
- +5 in binary: 00000101
- Invert bits: 11111010
- Add 1: 11111011
So -5 is represented as 11111011 in two's complement!
This system is brilliant because addition and subtraction work the same way for positive and negative numbers. When your calculator computes 7 + (-3), it's actually adding 00000111 + 11111101 = 00000100 (which is 4) - and the carry bit is simply ignored! This makes electronic circuits much simpler to design.
Real-World Applications in Electronics
students, these number systems aren't just academic concepts - they're the foundation of modern technology! š
In microcontrollers (tiny computers inside everything from washing machines to cars), programmers use hex to set configuration registers. For example, writing 0xFF to a port might turn on all 8 LEDs connected to it, while 0x55 would create a checkerboard pattern.
Memory addressing relies heavily on hex. Your computer's RAM might have addresses like 0x1000A000, and each address points to a specific byte of data. Graphics cards use hex to represent colors - #FF0000 is pure red, #00FF00 is pure green, and #0000FF is pure blue.
Even in digital audio, binary represents sound waves as numbers. A CD samples sound 44,100 times per second, storing each sample as a 16-bit binary number. That's why a CD can hold about 74 minutes of music!
Network engineers use hex when analyzing data packets traveling across the internet. Each packet header contains hex values that specify source addresses, destination addresses, and data types.
Conclusion
Congratulations, students! š You've just mastered the fundamental number systems that power our digital world. You now understand how binary mirrors the ON/OFF nature of electronics, how hexadecimal makes complex binary data manageable for humans, and how two's complement elegantly handles negative numbers in digital systems. These concepts form the backbone of everything from simple LED circuits to complex computer processors. Whether you're programming microcontrollers, analyzing digital signals, or designing electronic systems, these number systems will be your constant companions in the exciting field of electronics!
Study Notes
⢠Decimal (Base 10): Uses digits 0-9, each position represents powers of 10
⢠Binary (Base 2): Uses digits 0-1, each position represents powers of 2
⢠Hexadecimal (Base 16): Uses 0-9 and A-F, each position represents powers of 16
⢠Bit: One binary digit (0 or 1)
⢠Byte: 8 bits, can represent 256 different values (0-255)
⢠Binary to Decimal: Multiply each bit by its position value (power of 2) and sum
⢠Decimal to Binary: Repeatedly divide by 2, track remainders, read bottom to top
⢠Binary to Hex: Group 4 bits together, convert each group to hex digit
⢠Hex to Binary: Convert each hex digit to 4 bits
⢠Two's Complement: Method for representing negative numbers in binary
⢠Two's Complement Process: 1) Write positive binary, 2) Invert all bits, 3) Add 1
⢠Sign Bit: In two's complement, leftmost bit indicates sign (0=positive, 1=negative)
⢠Hex Color Codes: #RRGGBB format where each pair represents red, green, blue values
⢠Memory Addresses: Typically written in hexadecimal for compact representation
