warning: left shift count >= width of type
long
may be a 64-bit type, but 1
is still an int
. You need to make 1
a long int
using the L
suffix:
unsigned long x = 1UL << 32;
(You should also make it unsigned
using the U
suffix as I've shown, to avoid the issues of left shifting a signed integer. There's no problem when a long
is 64 bits wide and you shift by 32 bits, but it would be a problem if you shifted 63 bits)
unsigned long
is 32 bit or 64 bit which depends on your system. unsigned long long
is always 64 bit. You should do it as follows:
unsigned long long x = 1ULL << 32
unsigned long x = 1UL << 31;
Not show the error message. Because before you specify the 32, is not true because only limited to 0-31.