Number Systems

Bismillahir Rahmanir Rahim
Understanding Number Systems: Decimal, Binary, and Hexadecimal
Nice to meet you again! While you are likely accustomed to working with everyday decimal numbers, digital systems rely heavily on Binary (0s and 1s) and Hexadecimal systems. This is primarily due to their convenience and efficiency in hardware design and programming.
Let's break down how these systems work and how to seamlessly convert between them.
1. Decimal Digits (Base 10)
The decimal system uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Each column represents a value that is 10 times more than the previous column (reading from right to left). These are also called Base 10 numbers because we represent each column as a multiple of a power of 10.
Capacity: An
N-digit decimal number can represent up to10ᴺpossibilities.Example: A 3-digit number has
10³ = 1000possibilities (ranging from000to999).
2. Binary Numbers (Base 2)
In the binary system, "bits" represent only one of two values: 0 or 1. Each column carries twice the weight of the previous column, making this a Base 2 system.
The Powers of 2 Table
If you work in programming or IT, you will save significant time by memorizing the powers of 2 up to 2¹⁶:
| Power | Value | Power | Value | |
|---|---|---|---|---|
2⁰ |
1 | 2⁹ |
512 | |
2¹ |
2 | 2¹⁰ |
1024 (1k) | |
2² |
4 | 2¹¹ |
2048 | |
2³ |
8 | 2¹² |
4096 | |
2⁴ |
16 | 2¹³ |
8192 | |
2⁵ |
32 | 2¹⁴ |
16384 | |
2⁶ |
64 | 2¹⁵ |
32768 | |
2⁷ |
128 | 2¹⁶ |
65536 | |
2⁸ |
256 |
Converting Binary to Decimal: Let's convert
1101(binary) to decimal: =(1 * 2³) + (1 * 2²) + (0 * 2¹) + (1 * 2⁰)=8 + 4 + 0 + 1=13(decimal)
3. Hexadecimal Numbers (Base 16)
Binary numbers can become very long and prone to errors when written out. To simplify this, we use Hexadecimal (Base 16).
A group of 4 bits gives us 16 possibilities (2⁴ = 16). With just one hexadecimal digit, we can represent an entire 4-bit sequence!
Hexadecimal Conversion Table
| Decimal | Hex | Binary | Decimal | Hex | Binary | |
|---|---|---|---|---|---|---|
| 0 | 0 |
0000 |
8 | 8 |
1000 |
|
| 1 | 1 |
0001 |
9 | 9 |
1001 |
|
| 2 | 2 |
0010 |
10 | A |
1010 |
|
| 3 | 3 |
0011 |
11 | B |
1011 |
|
| 4 | 4 |
0100 |
12 | C |
1100 |
|
| 5 | 5 |
0101 |
13 | D |
1101 |
|
| 6 | 6 |
0110 |
14 | E |
1110 |
|
| 7 | 7 |
0111 |
15 | F |
1111 |
4. Practical Conversions
Here is how you can practically convert numbers between these three systems.
A. Hexadecimal to Binary and Decimal
Goal: Convert 2ED (hex) to binary and decimal.
Hex to Binary: Map each character using the table above.
2=0010E=1110D=1101Result:
001011101101(binary)
Hex to Decimal: Multiply by powers of 16.
=
(2 * 16²) + (14 * 16¹) + (13 * 16⁰)=
512 + 224 + 13Result:
749(decimal)
B. Binary to Hexadecimal
Goal: Convert 1111010 (binary) to hexadecimal.
Group into 4 bits: Start from the right. Pad with leading zeros if necessary:
0111and1010.Map to Hex: *
1010=A0111=7
Result:
7A(hex)
C. Decimal to Hexadecimal and Binary
Goal: Convert 333 (decimal) to hexadecimal and binary.
There are two primary methods for doing this: the Subtraction Method and the Repeated Division Method.
Method 1: The Subtraction Method (Descending Powers)
You subtract the largest possible power of the target base until you reach zero.
Decimal to Hexadecimal:
The largest power of 16 less than 333 is 256 (which is
16²).256 goes into 333 once (
1 * 256). Remainder:333 - 256 = 77.16 goes into 77 four times (
4 * 16 = 64). Remainder:77 - 64 = 13.13 in decimal is D in hex.
Hex Result:
14D(hex)
Decimal to Binary:
333 - 256(which is2⁸) = 7777 - 64(which is2⁶) = 1313 - 8(which is2³) = 55 - 4(which is2²) = 11 - 1(which is2⁰) = 0
Since binary digits exist at the positions for
2⁸,2⁶,2³,2², and2⁰, we place a1in those columns and a0everywhere else.Binary Result:
101001101
Method 2: Repeated Division (The Remainder Method)
This is often the easiest method for programming or working with large numbers. You repeatedly divide the decimal number by the target base (2 or 16) and record the remainders. Read the remainders from bottom to top to get your answer.
Decimal to Hexadecimal (Divide by 16):
333 ÷ 16= 20, remainder 13 (which is Hex D)20 ÷ 16= 1, remainder 4 (which is Hex 4)1 ÷ 16= 0, remainder 1 (which is Hex 1)
- Read bottom to top Result:
14D(hex)
Decimal to Binary (Divide by 2):
333 ÷ 2= 166, remainder 1166 ÷ 2= 83, remainder 083 ÷ 2= 41, remainder 141 ÷ 2= 20, remainder 120 ÷ 2= 10, remainder 010 ÷ 2= 5, remainder 05 ÷ 2= 2, remainder 12 ÷ 2= 1, remainder 01 ÷ 2= 0, remainder 1
- Read bottom to top Result:
101001101(binary)



