How do I bit shift a long by more than 32 bits?

c, c++

Solution

Re-try this using a variable of type `uint64_t` (from `stdint.h`) instead of `long`. `uint64_t` is guaranteed to be 64 bits long and should behave as you expect.

Problem

It seems like I should be able to perform bit shift in C/C++ by more than 32 bits provided the left operand of the shift is a long. But this doesn't seem to work, at least with the g++ compiler. Example: ``` unsigned long A = (1L << 37) ``` gives ``` A = 0 ``` which isn't what I want. Am I missing something or is this just not possible? -J

Original source

Related problems