I have doubt about the multiplication of unsigned long long int in the G++ 5.4.0 compiler. Why the 1st snippet overflows even though the variable n is unsigned long long int type? Why the 'LL' behind 8 works?
Please give me some keyword that I can dig more about this problem. Thanks!
//WRONG RESULT: 1549413176
int main(){
unsigned long long int n = 1804289383;
std::cout<<n * 8 <<endl;
return 0;
}
//Correct :14434315064
int main(){
unsigned long long int n = 1804289383;
std::cout<<n * 8LL <<endl;
return 0;
}
compiler: g++ 5.4.0