H
HARDCORECODER
ok I want to extract the first 4 bits of a 32 bit interger. The SIZE
doesn't really matter. 8,16, 0r 32. I want the first 4 bits.....bit
0,1,2 and,3. I want to exract these and place into another variable.
here is my Idea
int bits1to3=(x>>1)&0x0f; // bits 1 2 3 4
or
long bits1to3=(x>>12)&0x0f; // bits 12 13 14 15
to extract bit field I should shift right then use a bit mask
containing all ones. This will store the first 4 bits into bits1to3
right?
I beleive this is correct! but anyone else have suggestions?
doesn't really matter. 8,16, 0r 32. I want the first 4 bits.....bit
0,1,2 and,3. I want to exract these and place into another variable.
here is my Idea
int bits1to3=(x>>1)&0x0f; // bits 1 2 3 4
or
long bits1to3=(x>>12)&0x0f; // bits 12 13 14 15
to extract bit field I should shift right then use a bit mask
containing all ones. This will store the first 4 bits into bits1to3
right?
I beleive this is correct! but anyone else have suggestions?