L
lancer6238
Hi all,
I'm using RedHat Enterprise Linux 4 and gcc version 3.4.6. It is my
understanding that unsigned int can only represent positive numbers,
i.e. values 0 or larger. However, why is it that the code below works?
unsigned int i;
i = -5;
printf("%d\n", i);
The program prints -5. How is the negative number represented when "i"
should not have a sign bit?
Also, how do I verify that a data type, e.g. size_t, is indeed
unsigned, if an unsigned data type is able to represent a negative
number, like in the above example?
Thank you.
Regards,
Rayne
I'm using RedHat Enterprise Linux 4 and gcc version 3.4.6. It is my
understanding that unsigned int can only represent positive numbers,
i.e. values 0 or larger. However, why is it that the code below works?
unsigned int i;
i = -5;
printf("%d\n", i);
The program prints -5. How is the negative number represented when "i"
should not have a sign bit?
Also, how do I verify that a data type, e.g. size_t, is indeed
unsigned, if an unsigned data type is able to represent a negative
number, like in the above example?
Thank you.
Regards,
Rayne