Number Systems in Computer Science
г. Москва, Ленинский пр-кт д.71/91
8-901-572-77-70   +7 (499) 272-41-24
Дата публикации: 30.06.2025

Number Systems in Computer Science

Example 1: Convert the decimal number 42 to binary.

Solution:

  1. Divide the decimal number by 2 and write down the remainder.
    • 42 ÷ 2 = 21, remainder 0
  2. Divide the quotient from step 1 by 2 and write down the remainder.
    • 21 ÷ 2 = 10, remainder 1
  3. 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
  4. 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:

  1. Divide the decimal number by 16 and write down the remainder.
    • 164 ÷ 16 = 10, remainder 4 (A in hexadecimal)
  2. Divide the quotient from step 1 by 16 and write down the remainder.
    • 10 ÷ 16 = 0, remainder 10 (A in hexadecimal)
  3. Write down the remainders in reverse order.
    • The hexadecimal representation of 164 is AA.

Answer: The hexadecimal representation of 164 is AA.