wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

How do we store numeric values?

We actually saw how numeric values (well, actually integers) were stored when we first investigated how to add in decimal. We know:

Decimal     Binary      Next Decimal Number    Next Binary Number

      0                     0             0 + 1 = 1                                0 + 1 = 1
      1                     1             1 + 1 = 2                                1 + 1 = 10
      2                   10             2 + 1 = 3                              10 + 1 = 11
      3                   11             3 + 1 = 4                              11 + 1 = 100
      4                 100             4 + 1 = 5                            100 + 1 = 101
      5                 101             5 + 1 = 6                            101 + 1 = 110
      6                 110             6 + 1 = 7                            110 + 1 = 111
      7                 111             7 + 1 = 8                            111 + 1 = 1000
      8               1000             8 + 1 = 9                          1000 + 1 = 1001
      9               1001             9 + 1 = 10                        1001 + 1 = 1010
    10               1010           10 + 1 = 11                       1010 + 1 = 1011
    11               1011           11 + 1 = 12                       1011 + 1 = 1100
    12               1100           12 + 1 = 13                       1100 + 1 = 1101
    13               1101           13 + 1 = 14                       1101 + 1 = 1110
    14               1110           14 + 1 = 15                       1110 + 1 = 1111
    15               1111           15 + 1 = 16                       1111 + 1 = 10000

And so forth. As an example the value 12 (which we can see from the table above is 11002) is stored as:

Remember, from previous tutorials, we can also predict how many bits we need to represent a number:

21   =    2 combinations (the integers 0 and 1)
22   =    4 combinations (the integers 0 through 3)
23   =    8 combinations (the integers 0 through 7)
24   =  16 combinations (the integers 0 through 15)

If we were to continue we would know:

If we had 5 bits:   25 =   32 combinations (we could represent all integers from 0 to 31)
if we had 6 bits:   26 =   64 combinations (we could represent all integers from 0 to 63)
If we had 7 bits:   27 = 128 combinations (we could represent all integers from 0 to 127)
If we had 8 bits:   28 = 256 combinations (we could represent all integers from 0 to 255)

But suppose I wanted to store the numeric value 1,254. How would I do it???

Stay Tuned. We will get to that soon.

Questions you should be able to answer:

  1. How would we store the numeric value 14 in RAM?

  2. If we had 8 light switches, what integers could we store?

Answers:

  1. From the table, we can see that we would store is as 11102, or:


     

  2. If we had 8 light switches (bits) we could store  28 = 256 combinations or all of the integers from 0 to 255

This page was last updated on 05/25/05.