First page Back Continue Last page Overview Graphics
Two's Complement
Exploits finite size of data representations (cyclic groups) and properties of binary arithmetic.
To get negative of binary number, invert all bits and add 1 to the result.
- e.g. 1 = 0 0 0 0 0 0 0 1 in 8-bit
- invert bits: 1 1 1 1 1 1 1 0
- add 1: 0 0 0 0 0 0 0 1
- result: 1 1 1 1 1 1 1 1 = -1
In 8 bits, signed char ranges from -128 to +127.
Notes: