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

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:

Integer Type

Number Bits

Number Combinations

Non-Negative Integer Range

Numeric Byte 8 28 = 256 0 - 255
Short Integer 16 216 = 65,536 0 - 65,535
Integer 32 232 = 4,294,967,296 0 - 4,294,967,295
Long Integer ** 64 264 = 18,446,744,073,709,551,616 0 - 18,446,744,073,709,551,616

** 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 ???
Can't we store negative integers in the computer ??

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:

  1. Instead of just doubling the number of bytes to increase the number of integers I could represent, why not just add a few additional bits?

Because the basic addressable unit is a byte, we add bits in multiples of 8.

  1. If I had 24-bits, what is the range of non-negative integers I could represent?

224 = 16,777,216 combinations so that we could represent all of the non-negative integers from 0 to 16,777,215

This page was last updated on 05/28/05