11.1.2 Signed and Unsigned Types

An unsigned integer type can represent only positive numbers and zero. A signed type can represent both positive and negative numbers, in a range spread almost equally on both sides of zero. For instance, unsigned char holds numbers from 0 to 255 (on most computers), while signed char holds numbers from −128 to 127. Each of these types holds 256 different possible values, since they are both 8 bits wide.

Write signed or unsigned before the type keyword to specify a signed or an unsigned type. However, the integer types other than char are signed by default; with them, signed is a no-op.

Plain char may be signed or unsigned; this depends on the compiler, the machine in use, and its operating system. It is not the same type as either signed char or unsigned char, but it is always equivalent to one of those two.

In many programs, it makes no difference whether the type char is signed. When signedness does matter for a certain vslue, don’t leave it to chance; declare it as signed char or unsigned char instead.4


Footnotes

(4)

Personal note from Richard Stallman: Eating with hackers at a fish restaurant, I ordered arctic char. When my meal arrived, I noted that the chef had not signed it. So I told other hackers, “This char is unsigned—I wanted a signed char!”