I would like to put the same thing that was said into a little
different terms, and an easy way to figure it, for me, anyways.
As was said before in almost every post before me, 1 byte = 8 bits;
therefore, 2 bytes = 16 bits. As was mentioned before, this
determines how big of a number you can actually store in this data
type. So, if there are only two possibilities in a computer 1 and 0,
then the number of possible combinations you can have is 2 ^ 16 which
equals 65,536.
It stores 1 bit as a positive or negative number, so on the number
line, you would have 0 - +xxx, and -xxx - 0. To find what max values
it can reach you would break it in half. 65,536 / 2 = 32768 max
values in the positive or negative range. If you did not have a 0,
then it's range would be from -32,768 - +32,768, but since we have an
additional 0, 1 is subtracted from the negative spectrum, representing
the full range of values, -32,767 - +32,768.
I know that this has already been said earlier, but in a different
fashion. This is how I think of it in my mind. Sometimes it helps to
get a different way of looking at it to help.
This method will show you how to determine the largest values for any
integer datatype that you work with, regardless of size. Let me show
you. If you want to figure out what the range of values are for a
1,024 bit integer, you would find that it would be 2 ^ 1,024 =
1.79E308 / 2 = -8.98E307 - +8.98E307.
Might come in handy if you ever have to program a spaceship travel
route to the sun, or Halley's comet.
