B
Boltar
On 32 bit linux with gcc 4.2 I get unexpected results with this code:
main()
{
int bits = 32;
printf("%d\n",(int)1 << (int)32);
printf("%d\n",(int)1 << bits);
}
The first printf gives a result of 0, the second gives 1. I checked
with sizeof() and ints are definately 32 bits in size.
I'm sure I'm missing something obvious but can someone tell me what?
Thanks
B2003
main()
{
int bits = 32;
printf("%d\n",(int)1 << (int)32);
printf("%d\n",(int)1 << bits);
}
The first printf gives a result of 0, the second gives 1. I checked
with sizeof() and ints are definately 32 bits in size.
I'm sure I'm missing something obvious but can someone tell me what?
Thanks
B2003