Binary & Number Systems
Understand how computers represent all data using binary, and how different number systems like decimal, octal, and hexadecimal relate to each other.
Why Binary?
Computers are built from billions of tiny switches called transistors. Each transistor can be either ON (1) or OFF (0). This two-state nature makes the binary (base-2) number system the natural language of all digital hardware.
Every image, video, song, and program you've ever used is ultimately stored and processed as a sequence of 0s and 1s.
Common Number Systems
- Binary (Base-2) โ Uses digits 0 and 1. Example:
1011= 11 in decimal. - Decimal (Base-10) โ The everyday system. Uses digits 0โ9.
- Octal (Base-8) โ Uses digits 0โ7. Often used in file permission systems (e.g., Unix chmod).
- Hexadecimal (Base-16) โ Uses digits 0โ9 and letters AโF. Widely used to represent memory addresses and color codes (e.g.,
#FF5733).
Converting Binary to Decimal
Each binary digit (bit) represents a power of 2, starting from the rightmost bit (2โฐ).
Binary: 1 0 1 1
Powers: 2ยณ 2ยฒ 2ยน 2โฐ
Values: 8 0 2 1
Sum: 8 + 0 + 2 + 1 = 11 Hexadecimal Quick Reference
0โ9map to values 0โ9A = 10, B = 11, C = 12, D = 13, E = 14, F = 15- Example:
0xFF= 255 in decimal (15ร16 + 15) - Colors in CSS:
#RRGGBBโ each pair is a hex byte (0โ255) for Red, Green, Blue.
Bits, Bytes & Beyond
- 1 Bit โ A single 0 or 1.
- 4 Bits (Nibble) โ Half a byte; represents one hex digit.
- 8 Bits (Byte) โ The standard unit; can represent 256 values (0โ255).
- ASCII โ A standard that maps bytes to characters (e.g., 65 = 'A').
- Unicode (UTF-8) โ A modern standard supporting all world languages and emoji.
Binary Arithmetic
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry 1). This is exactly how your CPU's Arithmetic Logic Unit (ALU) works at the hardware level.
What's Next?
Now that you understand number systems, explore Computer Architecture to see how the CPU uses binary arithmetic, or check out Data Structures to learn how data is organized in memory.