Reputation: 6475
Am i correct to say follows:
the variable of unsigned int
take the whole 32 bits to represent a non-negative integer use two's complement. So the range of integer it can hold is from 0 to (2^32) - 1.
the variable of int
take the whole 32 bits to represent a integer use two's complement. So the range of integer it can hold is from -(2^31) to (2^31) - 1.
e, i say that in the situation of a machine which word size is 32bits.
Upvotes: 1
Views: 255
Reputation: 1482
It is probably so most of the time. However the C standard only requires int
to be a signed integer at least 16 bits in size and unsigned int
to be an unsigned integer at least 16 bits in size.
See: http://en.wikipedia.org/wiki/C_data_types
Especially:
The type int should be the integer type that the target processor is most efficient working with. This allows great flexibility: for example, all types can be 64-bit. However, several different integer width schemes (data models) are popular. This is because the data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.
Upvotes: 6