Is it equivalent to a unsigned integer ?开发者_如何转开发
I'm able to use unsigned unknown_type_var = 3332934; and print it successfully. This value is greater than a integer variable right ?unsigned is totally equivalent to unsigned int, just like long is equivalent to long int, etc.
It is same as unsigned int
. By default the type is int
.
The max value for unsigned int
is 4294967295
. This limits are defined in the LIMITS.H header file. Refer http://msdn.microsoft.com/en-us/library/7fh3a000.aspx.
unsigned just means that it doesn't use the first bit as a sign (positive, negative) so it is always positive and has twice the capacity of a signed any_variable.
This stackoverflow question should help explain signed and unsigned variables in depth: What does the C++ standard state the size of int, long type to be?
Most C implementations use 4 bytes for integers so that's a range between ~-2bil to ~2bil or 0 to 4bil for unsigned ints so your variable is well within the range of an interger.
精彩评论