difference between ( x = 1<<32 ) and ( x = 1LL<<32 )
Explanation required
LL stands for LongLong, which means at least 64-bit
( x = 1<<32 ) this will work in 32 bits form
( x = 1LL<<32 ) this will work with 64 bits
why is the output not correct in the first case.
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x=1<<32;
cout<<x;
return 0;
}
Output is coming out to be 0
1<<32 will work on 32 bits.
So 00000000…(31 times)…1 <<32 will actually give you zero.(1 is shifted left 32 positions but rem posn were 31)
But with LL<<32 it will not give 0 as it works on 64 bits.