# Signed and unsigned

• 09-17-2007
alyeska
Signed and unsigned
What exactly are signed and unsigned numbers? Please clarify.
Thanks..
• 09-17-2007
CodeMonkey
In a strictly lingual sense, signed numbers may be negative or positive, while unsigned numbers are taken as positive. Usually, unsigned numbers can represent greater values, since in most implementations no space is left for a sign in an unsigned number.
• 09-18-2007
Abda92
Like the monkey explained, signed numbers can be positive or negative. Unsigned numbers are always positive.

In C++, unsigned variables can hold larger numbers, since all 8 bits (assuming the variable is 1 byte) can be used. While in signed variables, the last bit is used for the sign.
• 09-18-2007
robatino
Strictly speaking, unsigned numbers are nonnegative, not necessarily positive.
• 09-18-2007
alyeska
How about the range? Why 0 to 255 for unsigned and -128 to 127 for signed in 1 byte? I don't quite get that. Can somebody please explain further?
• 09-18-2007
robatino
Signed types need 1 bit for the sign, which means the maximum absolute value is approximately 1/2 that of an unsigned type. The C and C++ standards allow three types of signed integral arithmetic: two's complement, ones' complement, and sign-magnitude. Most modern machines use two's complement, in which there is one extra value at the negative end (for example -128 to +127). Ones' complement and sign-magnitude have a symmetric range (for example -127 to +127).

Edit: http://en.wikipedia.org/wiki/Signed_...epresentations