28 November 2009

Decimal to Binary Conversion

I hope this guide will be helpful.

You have an integer... (i.e. 75)
1) Divide the integer by 2. (i.e. 75/2 = 37.5)
2) Make the previous answer into quotient and remainder format.
(i.e. Remove the 0.5 in 37.5, you get 37. Then to get the remainder, multiply 37 by the integer
you used to perform the previous division, which is 2, to get 74. Finally, subtract away from
previous quotient or starting integer, 75-74=1. That's the remainder.)
3) With the quotient, divide it by 2. Do this for all the quotients until you get 1 as the quotient.
4) The final quotient will be the MSB of the binary and the first remainder will be the LSB.
5) You now have your integer as binary. (i.e. 1001011)

Illustrated example:
2)_75__
2)_37__ R=1 (LSB)
2)_18__ R=1
2)_9___ R=0
2)_4___ R=1
2)_2___ R=0
1 R=0
^(MSB)

From MSB to LSB, you get 1001011.

0 comments: