CIS3355:
Business Data Structures |
How do we store integers larger than 255? As we noted in the previous tutorial, if we only have 8-bits, we can only have 28 = 256 combinations, and therefore we could only represent the integers from 0 to 255. If we want to store larger integers: We need to add more bits! .How many??? Depends. Since we know that the basic addressable unit is a byte, we should add bits in multiples of 8. .So, we should add 8-more bits, for a total of 16 ??? We could. In fact the original data type Integer on the PC consisted of 16-bits. Now we have a number of different types of integers, each requiring a different number of bits. Some of the more common representations are:
** As of the time of this writing, longs on the PC are still 32-bits As we can see, as we add more bits, we exponentially increase the size of the integers we can represent (we know that every time we add a bit, we double the amount of information we can represent). .You
keep using the term 'non-negative' integers ??? Yes! As a matter of fact, the default (i.e., unless we specify otherwise, that is how they will be stored) way of storing integers is to allow them to take on either negative or negative values. How do we do that ??? We'll get to that shortly. Some questions you should be able to answer:
|