3. Signed integer
While unsigned integers are very efficient, they are limited to positive numbers. When the programmer expects that the software will have to deal with both positive and negative numbers, they have to use a different type of integer. This is the signed integer.
Just like unsigned integer a signed integer can be long (4 bytes) or short (2 bytes). For a signed integer, the leftmost bit indicates the sign of the number. This halves the range of positive numbers that a signed integer can represent, relative to an unsigned integer.
For a 16 bit signed short integer, the largest positive number is
0111 1111 1111 1111
Which is ($2^{15} - 1$) - because 15 bits are used for the magnitude, and it is -1 because it includes zero. In denary this is 32,767.
For a 16 bit signed short integer, the largest negative number is
1111 1111 1111 1111
Which is -($2^{15}$) because 15 bits are used for the magnitude. In denary this is -32,768.
In a typical computer language ('C' for example), a signed short integer is fully declared like this
signed short int MyVariable
or just
int MyVariable
if it defaults to signed short integer anyway.
A long signed integer is typically declared like this
signed long int MyVariable
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: Range of signed integer