19.5. Signed and Unsigned Integral Types

[ fromfile: twoscomplement.xml id: twoscomplement ]

8-bit Integer Example

Suppose that you have a tiny system that uses only 8 bits to represent a number. On this system, the largest unsigned integer would be

11111111 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

But that same number, interpreted as a signed integer, would be

11111111 = -128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = -1