#include <stdio.h>
#include <stdint.h>
uint32_t gethex(uint32_t var, int index, int count) {
uint32_t rev = 0;
for (int i = 0; i < count; i++) {
rev = (rev << 4) | ((var >> (4 * (index + i))) & 0xF);
}
return rev;
}
int main() {
uint32_t var = 0x32413564; // Binary: 0011 0010 0100 0001 0011 0101 0110 0100
uint32_t ret = gethex(var, 5, 3); // Get 3 bits starting from the 4th bit (index 4)
printf("%X\n", ret);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: