D
Digital Puer
I'd like to be able to create an integer from a range of contiguous
bits
in another integer. I'm on a big-ending machine, in case that matters.
I would ideally like to create a function with this prototype:
unsigned long long extractValue(unsigned long long target, int a, int
b)
where a and b are the range of bits counted off from the most
significant
bit (where the msb is the 0th bit). For instance, 12345678900 is
00000000 00000000 00000000 00000010 11011111 11011100 00011100
00110100
A call to extractValue(value, 32, 35) should result in 13 (1101 in
binary).
Can someone please help?
bits
in another integer. I'm on a big-ending machine, in case that matters.
I would ideally like to create a function with this prototype:
unsigned long long extractValue(unsigned long long target, int a, int
b)
where a and b are the range of bits counted off from the most
significant
bit (where the msb is the 0th bit). For instance, 12345678900 is
00000000 00000000 00000000 00000010 11011111 11011100 00011100
00110100
A call to extractValue(value, 32, 35) should result in 13 (1101 in
binary).
Can someone please help?