#informatique S1 05 exercices corrigés (TD 01)
Table of Contents
Introduction
This tutorial provides a comprehensive guide to converting numbers between different numerical bases, focusing on binary, octal, decimal, and hexadecimal systems. Understanding these conversions is crucial for various applications in computer science and programming.
Step 1: Understanding Numerical Bases
Before jumping into conversions, it’s essential to grasp the concept of numerical bases:
- Binary (Base 2): Uses two symbols, 0 and 1. Each digit represents a power of 2.
- Octal (Base 8): Uses eight symbols, 0 through 7. Each digit represents a power of 8.
- Decimal (Base 10): The standard system using ten symbols, 0 through 9.
- Hexadecimal (Base 16): Uses sixteen symbols, 0 through 9 and A through F, where A represents 10 and F represents 15.
Step 2: Converting Between Bases
Binary to Decimal
- Write down the binary number.
- Assign powers of 2 to each digit, starting from the right (0, 1, 2, ...).
- Multiply each digit by its corresponding power of 2.
- Sum all the results.
Example: Convert 1011 to decimal
- 1 × 2^3 + 0 × 2^2 + 1 × 2^1 + 1 × 2^0 = 8 + 0 + 2 + 1 = 11
Decimal to Binary
- Divide the decimal number by 2.
- Record the remainder (0 or 1).
- Continue dividing the quotient by 2 until it reaches zero.
- The binary number is the remainders read in reverse order.
Example: Convert 11 to binary
- 11 ÷ 2 = 5 (remainder 1)
- 5 ÷ 2 = 2 (remainder 1)
- 2 ÷ 2 = 1 (remainder 0)
- 1 ÷ 2 = 0 (remainder 1)
- Binary: 1011
Decimal to Octal
- Divide the decimal number by 8 and record the remainder.
- Continue dividing the quotient by 8 until it reaches zero.
- Read the remainders in reverse order.
Example: Convert 11 to octal
- 11 ÷ 8 = 1 (remainder 3)
- 1 ÷ 8 = 0 (remainder 1)
- Octal: 13
Binary to Octal
- Group the binary digits in sets of three, starting from the right. Add leading zeros if necessary.
- Convert each group to its octal equivalent.
Example: Convert 1011 to octal
- Group: 001 011
- Octal: 3 (from 011) and 1 (from 001) → 13
Octal to Decimal
- Write down the octal number.
- Assign powers of 8 to each digit.
- Multiply each digit by its corresponding power of 8.
- Sum all the results.
Example: Convert 13 to decimal
- 1 × 8^1 + 3 × 8^0 = 8 + 3 = 11
Conclusion
In this tutorial, we've covered the basics of converting numbers between binary, octal, decimal, and hexadecimal systems. Mastering these conversions is essential for anyone working in fields related to computing and information technology. To further enhance your understanding, practice with different numbers and conversions regularly.