Computin & Informatics: Decimal number to binary number

Write an algorithm to convert the decimal numbers into binary numbers. Explain your algorithm. (AMIE Summer 2014, 5 marks)

Answer

The following steps describe how to convert decimal to binary

  1. Divide the original decimal number by 2
  2. Divide the quotient by 2
  3. Repeat step 2 until we get a quotient equal to zero.
  4. The equivalent binary number would be remainders of each step in the reverse order.

Decimal to binary conversion with an example:

We want to convert decimal number 25 in the binary.

Step 1:  25 / 2  Remainder : 1 , Quotient : 12

Step 2:  12 / 2  Remainder : 0 , Quotient : 6

Step 3:   6 / 2  Remainder : 0 , Quotient : 3

Step 4:   3 / 2  Remainder : 1 , Quotient : 1

Step 5:   1 / 2  Remainder : 1 , Quotient : 0

So equivalent binary number is: 11001

That is (25)₁₀ = (11001)₂

---

The study material is available at https://amiestudycircle.com 

Comments

Popular posts from this blog

Design and Manufacturing: Selected short answer questions from AMIE exams (Summer 2017 to Summer 2020)

Mine Ventilation & Environmental Hazards: Selected Short Answer Questions from AMIE Exams