Integers: 1's complement | ||||||||||
Another way to represent negative values: | ||||||||||
Negate (flip) each bit. | ||||||||||
Use the operator ~ to represent flipping each bit. | ||||||||||
~B is B with all of its bits flipped. | ||||||||||
This is called 1's complement (1C). | ||||||||||
Example: 11ten is 01011 in 5-bit unsigned binary. Call this number B. | ||||||||||
B = 01011 | ||||||||||
-B = 10100 | ||||||||||