4.7. Fractional Values

We have learned to interpret binary numbers using place values based on powers of two. The value 1011 means 8 + 2 + 1 or 11 as we can see in this table:

Eights Fours Twos Ones
\(2^3\) \(2^2\) \(2^1\) \(2^0\)
1 0 1 1

Normally we think of this table as starting from the ones and extending to the left, with each new column representing one larger power of two than the preceding column - making each column twice as large as the column to its right. If we want to move from left to right, we must divide the current column’s value by 2 to calculate the next column. If we do this to the Ones column, we would get \(1/2\) (\(2^{-1}\)), then \(1/4\) (\(2^{-2}\)), then \(1/8\) (\(2^{-3}\)), etc…

1s 1/2s 1/4s 1/8s 1/16s 1/32s
\(2^0\) \(2^{-1}\) \(2^{-2}\) \(2{^-3}\) \(2^{-4}\) \(2^{-5}\)

           

These are the binary columns smaller than 1 that we have to work with: \(1/2\), \(1/4\), \(1/8\),… Any fractional value we want to represent, we must build using these fractions. Much like the decimal number \({0.34}_{10}\) means 3 tenths and 4 one-hundredths, the binary number \({0.11}_2\) means \(1/2 + 1/4 = {0.75}_{10}\)

Say I have the binary value \({0.0101}_2\). We can use the “table” method to convert the fractional value - we just need to line up the bits to the table so that the “.” falls on the line between 1 and 1/2:

1s 1/2s 1/4s 1/8s 1/16s 1/32s
\(2^0\) \(2^{-1}\) \(2^{-2}\) \(2{^-3}\) \(2^{-4}\) \(2^{-5}\)
0 1 0 1 0 0

We have a one in the columns representing 1/4th and 1/16th. So we have 0.25 + 0.0625 or 0.3125.

\({0.0101}_2 = {0.3125}_{10}\)

Limits of Fractional Representation

Say I ask you to make 0.6 using just 4 places to the right of the binary point (In base 10 we call . the decimal point. In base 2 it is the binary point. The generic term for it is radix point.) Try using this table and a calculator or some scratch paper and see what you come up with for a value for 0.6:

1s 1/2s 1/4s 1/8s 1/16s
\(2^0\) \(2^{-1}\) \(2^{-2}\) \(2{^-3}\) \(2^{-4}\)

       

There is no way to exactly represent the answer, you can just come close. (The closest you can come is 0.625). This is not a problem unique to binary, this is just a fact of trying to represent a value using a limited number of digits. Say I ask you to represent 2/3 as a decimal with only 2 decimal places… you could use 0.66, or 0.67, but could not accurately represent the simple value 2/3. The only difference with the 0.6 example is that some values that are easy to represent in decimal, like 6/10ths are harder to represent in binary.

Important

Often times when computers represent decimal fractions as binary numbers, the value stored is only an approximation of the true value. On the line below I have inserted code to have your web browser calculate the answer to 3 + .01 + .01:

Notice any issues?

Computers can be programmed to store numbers as decimal values (encoding each decimal digit as 4 binary ones), but that is much less efficient and is not necessarily more accurate (as the decimal system still has that it has trouble representing - like 1/3). But, if you are writing say financial software that needs to get exactly $3.02 when it adds two pennies to $3, you probably would be willing to use the less efficient representation!

Self Check

What decimal value does the binary number 0.111 represent?

    Q-12: What of the following is the binary representation of the decimal value 0.40625
  • 0.00011
  • That is 0.09375
  • 0.01010
  • That is 0.3125
  • 0.00111
  • That is 0.21875
  • 0.01101
  • 0.11001
  • That is 0.78125