c – Why GCC long long int can’t do 1
{
unsigned long long two16, two48 ;
two16 = 65536;
two48 = two16 * two16 * two16 ;
printf("2^48=%llX n",two48 );
two48 = 1<<48 ;
printf("Shifted 1<<48=%llX n",two48);
return 0 ;
}
When compiled on a 64 bit machine, with a word size of 8, the above gives a warning the two=1<<48 will overflow
left shift count >= width of type.
The output of the program is:
2^48=1000000000000
Shifted 1<<48=0
What is going on? Why can I not shift a 64bit quantity 48 bits?
Read more here: Source link