π’ Binary-Denary Conversion
π’ Converting Between Number Systems
Binary (base-2) and denary (base-10) are two different number systems used in computing. Understanding how to convert between these systems is fundamental to computer science and digital information processing.
Number Systems Overviewβ
π Denary (Base-10)β
- The number system we use daily
- Uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Position values are powers of 10 (10^0, 10^1, 10^2, etc.)
- Example: 425 = 4Γ10^2 + 2Γ10^1 + 5Γ10^0 = 400 + 20 + 5
0οΈβ£1οΈβ£ Binary (Base-2)β
- The number system used by computers
- Uses only 2 digits: 0 and 1 (called bits)
- Position values are powers of 2 (2^0, 2^1, 2^2, etc.)
- Example: 1011 = 1Γ2^3 + 0Γ2^2 + 1Γ2^1 + 1Γ2^0 = 8 + 0 + 2 + 1 = 11
π Converting Binary to Denaryβ
To convert a binary number to denary:
- Identify the position value of each bit (powers of 2 from right to left)
- Multiply each bit by its position value
- Sum all the results
Example 1: Convert 1010β to denaryβ
1 0 1 0
β β β β
2^3 2^2 2^1 2^0
8 4 2 1
β β β β
1Γ8 0Γ4 1Γ2 0Γ1
8 0 2 0
Sum: 8 + 0 + 2 + 0 = 10ββ
Example 2: Convert 11001β to denaryβ
1 1 0 0 1
β β β β β
2^4 2^3 2^2 2^1 2^0
16 8 4 2 1
β β β β β
1Γ16 1Γ8 0Γ4 0Γ2 1Γ1
16 8 0 0 1
Sum: 16 + 8 + 0 + 0 + 1 = 25ββ
π Converting Denary to Binaryβ
To convert a denary number to binary:
- Divide the number by 2
- Record the remainder (0 or 1)
- Continue dividing the quotient by 2 until the quotient becomes 0
- Read the remainders from bottom to top to get the binary number
Example 1: Convert 13ββ to binaryβ
Division Quotient Remainder
13 Γ· 2 6 1
6 Γ· 2 3 0
3 Γ· 2 1 1
1 Γ· 2 0 1
Reading remainders from bottom to top: 1101β
Example 2: Convert 42ββ to binaryβ
Division Quotient Remainder
42 Γ· 2 21 0
21 Γ· 2 10 1
10 Γ· 2 5 0
5 Γ· 2 2 1
2 Γ· 2 1 0
1 Γ· 2 0 1
Reading remainders from bottom to top: 101010β
π‘ Alternative Method: Powers of 2β
Another way to convert denary to binary is using powers of 2:
- Find the largest power of 2 less than or equal to the number
- Subtract this power of 2 from the number
- Continue with the remainder, finding the next largest power of 2
- Mark 1 for each power of 2 used, and 0 for those not used
Example: Convert 25ββ to binaryβ
- Largest power of 2 β€ 25 is 16 (2^4)
- 25 - 16 = 9
- Largest power of 2 β€ 9 is 8 (2^3)
- 9 - 8 = 1
- Largest power of 2 β€ 1 is 1 (2^0)
- 1 - 1 = 0
- Powers used: 2^4, 2^3, 2^0
- Binary representation: 11001β
π Practical Applicationsβ
Understanding binary-denary conversion is essential for:
- πΎ Interpreting binary data in computers
- π§ Understanding memory addresses and data storage
- π» Programming at the machine level
- β‘ Working with digital logic and circuits
- π§ Troubleshooting computer systems
These conversion skills form the foundation for more advanced topics in computer science and digital systems.