Why this code prints two different numbers for f1
and f2
?:
int main() {
int a = 32;
int f1 = (0xffffffff << a);
int f2 = (0xffffffff << 32);
std::cout << f1 << std::endl; // print -1
std::cout << f2 << std::endl; // print 0
}
For f2, I get this warning but nothing for f1:
warning: left shift count >= width of type
I am using g++ 4.4.7