Дата публикации: 30.06.2025
Number Systems in Computer Science
Example 1: Convert the decimal number 42 to binary.
Solution:
- Divide the decimal number by 2 and write down the remainder.
- 42 ÷ 2 = 21, remainder 0
- Divide the quotient from step 1 by 2 and write down the remainder.
- 21 ÷ 2 = 10, remainder 1
- Repeat step 2 until the quotient becomes 0.
- 10 ÷ 2 = 5, remainder 0
- 5 ÷ 2 = 2, remainder 1
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
- Write down the remainders in reverse order.
- The binary representation of 42 is 101010.
Answer: The binary representation of 42 is 101010.
Example 2: Convert the decimal number 164 to hexadecimal.
Solution:
- Divide the decimal number by 16 and write down the remainder.
- 164 ÷ 16 = 10, remainder 4 (A in hexadecimal)
- Divide the quotient from step 1 by 16 and write down the remainder.
- 10 ÷ 16 = 0, remainder 10 (A in hexadecimal)
- Write down the remainders in reverse order.
- The hexadecimal representation of 164 is AA.
Answer: The hexadecimal representation of 164 is AA.