--- Thomas Hruska wrote:
> The compiler is treating the resulting value as an unsigned integer
> because that is exactly what you told it to do with typecasting.
OK, I wrote a bad piece of code. Let me try to codify my problem again:
#include <limits.h>
#include <stdio.h>
int main (void) {
unsigned short int a;
unsigned long long int b, c;
a = USHRT_MAX;
b = (a*a);
c = ((unsigned int)a*(unsigned int)a);
printf ("Why %llx != %llx ?\n", b, c);
return 0;
}
When I execute it I get:
Why fffffffffffe0001 != fffe0001 ?
b is wrong.
Is this a compiler's bug?