2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by alexchen
0

An int can store negative numbers that usually range from about -2.1 billion to about 2.1 billion.

An unsigned int can only store positive numbers that usually range from 0 to about 4.2 billion.

In a 32-bit system, an int is typically 32-bits long with the first bit being the "sign bit". If the sign bit is "set", the number is considered negative. If you have an unsigned, the "sign bit" is ignored and is just considered another bit in the number.

sign bit
|
V
0000 0000 0000 0000 0000 0000 0000 0000  //this always represents zero (0)
|
V
1111 1111 1111 1111 1111 1111 1111 1111  //on most systems, this represents an int with a value of -1
X

1111 1111 1111 1111 1111 1111 1111 1111  //in an unsigned int, this represents 4,294,967,296 (about 4.2 billion)

Edited by Fbody: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.