next up previous contents
Next: Assignment (200 pts, due Up: Integer Representation Previous: Negative Values and Negation   Contents

Range of Values

Now that we understand how integer values are represented in binary, we can return to our original question. What is the range of numbers as Integer variables?

In Borland Pascal and Free Pascal, an Integer has 16 bits and it is signed. This means we interpret the most significant bit to know if the number is negative or not.

The largest value that can be represented is $0111 1111 1111 1111_2$, which is $2^{15}-1$, or 32767. The smallest value that can be represented is $1000 0000 0000 0000_2$. If you take the two's complement, it is still $1000 0000 0000 0000_2$. This means the smallest value is $-2^15$ or -32768.

In general, given $n$ bits to represent a signed integer, the largest value that can be presented is $2^{n-1}-1$, whereas the smallest value is $-2^{n-1}$



Tak Auyeung 2003-12-03