Representing Decimal Numbers in Binary


Constructing Numbers

Remember way back when you first learned how numbers were in base 10. You could break down the number into its parts (ones, tens, hundreds, thousands, etc.).

Given the decimal number 3045.125, it expands like this:

     3045.125 = (3*1000) + (0*100) + (4*10) + (5*1) + (1/10) + (2/100) + (5/1000)
Rewrite it as powers of 10:
              = (3*103) + (0*102) + (4*101) + (5*100) + (1*10-1) + (2*10-2) + (5*10-3) 
Simplify:
              =   300   +   0     +   40    +   5     +   .1     +   .02    +  .005
And do the arithmetic:
              =   3045.15
Binary numbers work in the exact same way, except that we use 2 as a base instead of 10.

Given the binary number 10110111.1011, it expands like this:

10110111.1011 = (1*128) + (0*64) + (1*32) + (1*16) + (0*8) + (1*4) + (1*2) + (1*1) + (1/2) + (0/4) + (1/8) + (1/16)
Rewrite as powers of 2 (integer portion):
10110111      = (1*27) + (0*26) + (1*25) + (1*24) + (0*23) + (1*22) + (1*21) + (1*20) 
Simplify:
              =  128   +   0    +   32   +   16   +   0   +    4    +   2    +   1
Rewrite as powers of 2 (fractional portion):
        .1011 = (1*2-1) + (0*2-2) + (1*2-3) + (1*2-4)
Simplify:
              =    .5   +    0    +  .125   +  .0625    
And do the arithmetic:
10110111.10112 = 183.687510
Condensed version:

Decimal:

      3045.125 = (3*1000) + (0*100) + (4*10) + (5*1) + (1/10) + (2/100) + (5/1000)
               = (3*103) + (0*102) + (4*101) + (5*100) + (1*10-1) + (2*10-2) + (5*10-3) 
               =   300   +   0     +   40    +   5     +   .1     +   .02    +  .005
               =   3045.15

Binary:

 10110111.1011 = (1*128) + (0*64) + (1*32) + (1*16) + (0*8) + (1*4) + (1*2) + (1*1) + (1/2) + (0/4) + (1/8) + (1/16)
 10110111      = (1*27) + (0*26) + (1*25) + (1*24) + (0*23) + (1*22) + (1*21) + (1*20) 
               =  128   +   0    +   32   +   16   +   0   +    4    +   2    +   1
               = 183
         .1011 = (1*2-1) + (0*2-2) + (1*2-3) + (1*2-4)
               =    .5   +    0    +  .125   +  .0625    
               = .6875
10110111.10112 = 183.687510

Binary vs. decimal fraction

             Decimal     Decimal
  Binary     fraction    value
-----------------------------------
  .1           1/2       .5      
  .01          1/4       .25     
  .001         1/8       .125     
  .0001        1/16      .0625       
  .00001       1/32      .03125
  .000001      1/64      .015625
  
  etc...
Examples of binary and decimal equivalents:
   Binary         Decimal (fraction)     Decimal
-------------------------------------------------
    1.1                1 1/2             1.5
    1.101              1 5/8             1.625
  101.001              5 1/8             5.125
 1001.0101             9 5/16            9.3125
 0011.10101            3 21/32           3.65625
Points
Reference values for integer portion (to the left of the point)
  Bit                    
Position   Exponent      Decimal                   Binary
--------------------------------------------------------------------
    1        20              1                         1 
    2        21              2                        10
    3        22              4                       100
    4        23              8                      1000
    5        24             16                     10000
    6        25             32                    100000
    7        26             64                   1000000
    8        27            128                  10000000
    9        28            256                 100000000
   10        29            512                1000000000
   11        210          1024               10000000000
   12        211          2048              100000000000
   13        212          4096             1000000000000
   14        213          8192            10000000000000
   15        214         16384           100000000000000 
   16        215         32768          1000000000000000
   17        216         65536         10000000000000000
   18        217        131072        100000000000000000
   19        218        262144       1000000000000000000
   20        219        524288      10000000000000000000
   21        220       1048576     100000000000000000000
   22        221       2097152    1000000000000000000000
   23        222       4194304   10000000000000000000000
   24        223       8388608  100000000000000000000000
   
   etc...
Example: 10010011001
 10000000000      2048
    10000000       128
       10000        16
        1000         8
+          1     +   1
------------     -----
 10010011001      2201
Reference values for fractional portion (to the right of the point):
  Bit                    Decimal              Decimal
Position   Exponent      Fraction             Number                    Binary
-------------------------------------------------------------------------------------------------------
    1        1/21              1/2     0.5000000000000000000000000   .1    
    2        1/22              1/4     0.2500000000000000000000000   .01
    3        1/23              1/8     0.1250000000000000000000000   .001
    4        1/24             1/16     0.0625000000000000000000000   .00001
    5        1/25             1/32     0.0312500000000000000000000   .000001
    6        1/26             1/64     0.0156250000000000000000000   .0000001
    7        1/27            1/128     0.0078125000000000000000000   .00000001
    8        1/28            1/256     0.0039062500000000000000000   .000000001
    9        1/29            1/512     0.0019531250000000000000000   .0000000001
   10        1/210          1/1024     0.0009765625000000000000000   .00000000001
   11        1/211          1/2048     0.0004882812500000000000000   .000000000001
   12        1/212          1/4096     0.0002441406250000000000000   .0000000000001
   13        1/213          1/8192     0.0001220703125000000000000   .00000000000001
   14        1/214         1/16384     0.0000610351562500000000000   .000000000000001
   15        1/215         1/32768     0.0000305175781250000000000   .0000000000000001
   16        1/216         1/65536     0.0000152587890625000000000   .00000000000000001
   17        1/217        1/131072     0.0000076293945312500000000   .000000000000000001
   18        1/218        1/262144     0.0000038146972656250000000   .0000000000000000001
   19        1/219        1/524288     0.0000019073486328125000000   .00000000000000000001
   20        1/220       1/1048576     0.0000009536743164062500000   .000000000000000000001
   21        1/221       1/2097152     0.0000004768371582031250000   .0000000000000000000001
   22        1/222       1/4194304     0.0000002384185791015625000   .00000000000000000000001
   23        1/223       1/8388608     0.0000001192092895507812500   .000000000000000000000001
   
   etc...
Binary/Decimal converter (BinConverter.exe)

Additional Resources: