Page 330 - Embedded Microprocessor Systems Real World Design
P. 330

multiplier of  1000. A 1K resistor, for example, is  1000 ohms, and lOOK dollars is $100,000.
                However, in the computer world, K means "multiply by 1024." So a 16bit-wide word can have
                65,536 possible values, or 64K (65,536/1024 = 64).
                   A similar rule applies to the term meg, or million. A I-meg resistor is 1,000,000 ohms. In
                computer lingo, a meg is 1024 x 1024, or 1,048,576.



                                              Floating Point

                A  limitation  on  any  integer  number  scheme,  regardless of  the  number  of  bits,  is  the
                difficulty in representing fractional numbers such as 2.54 or 3.3. When we looked at decimal
                numbers at the beginning of this appendix, we saw that they increase in powers of 10 as you
                move from  right  to left across the  digits. As you  move  to the  right of  the  decimal point,
                decimal numbers increase in negative powers of  10:
                          10'     10'    10"  . . .  lo-'   lo-?   1o-'i   1  o-4
                   Or     100     10     1    ....        .01     .001    ,0001
                                                   1
                Binary numbers work the same way:
                              22     2'    20   , . .  2-1   2-9   2-'3   2-+
                   Decimal    4      2     1   ...  .5    .25     .125   .0625

                And hex numbers as well:
                              16'     16'    16"   . . .  16-'   1 6-'   1
                   Decimal    256     16     1    . . .  .0625   .0039   .000244

                So we  can write a decimal number, such as 2.54, in binary and hex:
                                      2 54 = 010.100010100011~ = 2.8A316
                Note that in binary and hex, the number is a repeating value. Just like  1/3 is a repeating
                decimal in base 10 (but not in base 3), some fractional numbers cannot be exactly converted
                between bases.
                   We could represent fractional binary numbers in a computer by defining a 16bit number
                as ranging from zero to 4095 instead of zero to 65,535. 4096 values can be represented  by
                the  upper  12 bits of  the  l6bit word. This leaves the  lower  4 bits  available  to  represent
                fractional  values.  For  instance,  the  hex  value  1002 would  be  interpreted  as  100.2, or
                     + 2 x 16-', or 256.125 in decimal.
                   Such an arrangement makes calculations fairly easy and keeps everything in an integer
                format. However, the resolution of the fractional part of the number is limited, and there is
                a tradeoff between the accuracy of the fractional part and the maximum size of the number.
                The more bits that are allocated to the fractional part, the smaller the maximum number
                can be. The fewer bits allocated to the fractional part, the less precision we  have to repre-
                sent numbers with.
                   A better means of representing fractional values would emulate the decimal system that
                we  are already familiar with. If you have 4 decimal digits, you can write ,0001, 10, or 1000.
                All  these  numbers  use  4  digits, but  the  decimal point  can  move, or float,  to  represent


                Appendix B                                                           31 1
   325   326   327   328   329   330   331   332   333   334   335