-1

I want to do a simple bit mask operation. Lets say

uint64_t a = 348659235483;

Assuming this number is converted to binary, I want to extract the values from bit 6 to 12 (0 is MSB on the right end). What is the smallest code for that?

the binary is

10100010010110110110101101/110101/0011011

So I want to save 110101 which is 53

mahmood
  • 23,197
  • 49
  • 147
  • 242

1 Answers1

4

How about

uint64_t a = 348659235483;
uint64_t result = (a & 0x0fe0) >> 6;
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621