I have a problem shifting data to specific locations in a 64-bit register. I've done well in 32-bit register.
But this one gives a warning and also not shifting the data to the wanted location.

This one would work with shifts 0, 8, 16 and 24 but not with 32 or more.

uint64_t map_buffer=0;
map_buffer |= 0xff << 32;                 // loading data into map_buffer

So, if I want to shift this data to the last location in the 64-bit register, so the output should be like this: 0xff000000.

Recommended Answers

All 2 Replies

In MS Visual Studio you could use:
map_buffer |= 0xffULL << 32;

You could also just use a cast:
map_buffer |= (uint64_t)0xff << 32;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.