Decimal 2 Binary


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



Number we want to transform uses base X: we would like to transform this number into new one, that uses Y base. In this case we will use method of continuous dividing and multiplying (dividing numbers left of comma (,) with Y and multiplying numbers on the right side of comma, by Y - rational numbers). This method is best understood looking at these examples where X equals 10 (decimal base, B=10), and Y eqauls 2 (binary base, B=2)


Decimal System:


Base: 10
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9


Binary System:

Base: 2
Digits: 0, 1
Example: 27 (decimal) = 11011 2 (binary)




Decimal 2 Binary




Example


Transform 29 (decimal) into binary number - reading upwards, result is 111012


29 : 2 =  14 , remaining 1   20            last (smallest) digit
14 : 2 = 7 , remaining
0 21
7 : 2 = 3 , remaining 1 22
3 : 2 = 1 , remaining 1 23
1 : 2 = 0 , remaining 1 24 first digit

- end of procedure





Example

Transform 0,8125 (decimal) into binary number – reading downwards, result is 0,11012


0,8125  * 2 =      1, 625    2-1            first digit after zero
0,625 * 2 =
1, 25 2-2
0,25 * 2 = 0, 5 2-3
0,5 * 2 = 1, 0 2-4 last digit

0,0 end of procedure





Example

Transform 0,3 (decimal) into binary number – result is 0,01001 1001 1001… 2 shortly rounded = 0,010012


0,3  * 2 =      0, 6         2-1       first digit after zero
0,6 * 2 =
1, 2 2-2
--------
0,2 * 2 = 0, 4 2-3
0,4 * 2 = 0, 8 2-4
0,8 * 2 = 1, 6 2-5
0,6 * 2 = 1, 2 2-6
--------



procedure never ends





Example – Quick Method

Transform 53(decimal) into binary number using quick method


  53                                                                          25 + 24 + 22 + 20 =
- 32 -> 25 1*25 + 1*24 + 0*23 + 1*22 + 0*21 + 1*20 =

-------- 110101 2
21
- 16 -> 24
--------
5
- 4 -> 22
--------
1
- 1 -> 20
--------
0 -> end of procedure









Technorati Tags:
, , , , , , , , , , ,



1 Responses to “Decimal 2 Binary”

  1. Anonymous Anonymous 

    There is a quicker method.

Leave a Reply

      Convert to boldConvert to italicConvert to link

 


German Flag Spanish Flag French Flag Italian Flag Portuguese Flag Japanese Flag Korean Flag Chinese Flag British Flag


This Website is optimized for Firefox. Users browsing with Internet Explorer may encounter problems while viewing pages.


C++ Maniac



Learn C



Additional



#include



Learn Converting



Appendix


Links


Previous posts




Daily Lessons for programming in Visual Studio, using C code.