# Number Representation

## How did anyone come up with this?

• Use subtraction to derive signed (positive & negative) numbers
• Notice that the resulting number is almost the one's complement; call the new system "two's complement"
•
```
`   00000000`     0  (assume a borrow is possible)
` - 00000001`  -  1
` ----------`  -----
`   ????????`

`  100000000`     0  (show the 1 that will be borrowed)
` - 00000001`  -  1
` ----------`  -----
`   11111111`    -1  (two's complement)

`   11111111`    -1  (two's complement)
` - 00000001`  -  1
` ----------`  -----
`   11111110`    -2  (two's complement)

`   11111110`    -2  (two's complement)
` - 00000001`  -  1
` ----------`  -----
`   11111101`    -3  (two's complement)

`   10000001`  -127  (two's complement)
` - 00000001`  -  1
` ----------`  -----
`   10000000`  -128  (two's complement)```
• Whoa!
The range of numbers we can represent is (-128) … 127   not symmetric!
There are 128 negative numbers and 128 non-negative numbers (but one of these is 0).
In general, if we have n bits, the range is -2n-1 …  2n-1 - 1.