As far as signed binary numbers are concerned for a 32bit machine, the leftmost bit is allocated for the sign. When I try to calculate the smallest negative integer value which can be stored in a machine, i follow the following steps:
- I assign the most significant bit as 1 (because it is negative)
- I place 1's into the remaining bits, thus the number of 1's I have for the magnitude of the number is 31.
- I convert this binary number to decimal:
$$ 2^{30}+ 2^{29}+...+2^1+2^0=2^{31}-1 $$
- With the negative sign, the smallest number is $$1-2^{31}$$
However the following source says otherwise. It says the smallest value is $$ -2^{31}$$ on the third page.
https://www.uio.no/studier/emner/matnat/math/MAT-INF1100/h12/kompendiet/kap4.pdf
What am I doing wrong here?
The smallest negative number is a $1$ followed by $31$ zeros which is interpreted as $-2^{31}.$ Because twos' complement is essentially arithmetic modulo $2^{32},$ it would be equally logical to interpret it as $2^{31}.$ The negative value is chosen so that the negative integers are precisely those with a $1$ as the most significant bit.