How to convert decimal numbers to binary and binary by tlv10296

VIEWS: 12 PAGES: 2

									How to convert decimal numbers to binary and binary to decimal

Integers:
       Decimal to Binary:
             For example: 12


                         12               2

                         12
                                          6      2
                         0
                                         6
                                                 3          2
                                         0       2
                                                            1
                                                 1




                                        1100

              12 (Decimal) = 1100 (Binary)

       Binary To Decimal:
              For Example 10011

                              1 * 20   =1
                              1 * 21   =2 +
                              0 * 22   =0 +
                              0 * 23   =0 +
                              1 * 24   = 16 +
                                       = 19

                     10011 (Binary) = 19 (Decimal)
Fractions:
       Decimal To Binary:
             For Example: 0.6

      0.6 = a1 * 2-1 + a2 * 2-2 + ….. + an * 2-n
*2
      1.2 = a1 + a2 * 2-1 + ….. + an * 2-n+1           a1 = 1
      0.2 = a2 * 2-1 + a3 * 2-2 + ….. + an * 2-n+1
*2
      0.4 = a2 + a3 * 2-1 + a4 * 2-2….. + an * 2-n+2   a2 = 0
      0.4 = a3 * 2-1 + a4 * 2-2….. + an * 2-n+1
*2
      0.8 = a3 + a4 * 2-1 + a5 * 2-2….. + an * 2-n+3   a3 = 0
      0.8 = a4 * 2-1 + a5 * 2-2….. + an * 2-n+3
*2
      1.6 = a4 + a5 * 2-1 + a6 * 2-2….. + an * 2-n+4   a4 = 1
      0.6 = a5 * 2-1 + a6 * 2-2….. + an * 2-n+4
      Return to first step

      0.6 (Decimal) = 0.100110011001100110011001100…………
      0.6(decimal )  0.1001100 ( Binary )

      Binary to Decimal
             For Example: 0.11001

      0.11001
             1 * 2-1   = 1/2
             1 * 2-2   = 1/4
             0 * 2-3   =0
             0 * 2-4   =0
             1 * 2-5   = 1/32

       (16  8  1) / 32  25 / 32 = 0.78125

								
To top