bit shifting with unsigned long type produces wrong results

1 << 63 will be computed in int arithmetic, and your int is probably 32 bit.

Remedy this by promoting one of the arguments: 1ULL << 63 will do it.

ULL means the expression will be at least 64 bits.

Leave a Comment