#include <stdio.h> #include <stdint.h> #include <math.h> uint8_t extract_field(uint16_t reg) { // Your logic here uint16_t mask = ((uint16_t)pow(2,5) - 1) << 4; reg = (reg & mask)>>4; return uint8_t(reg); } int main() { uint16_t reg; scanf("%hx", ®); printf("%u", extract_field(reg)); return 0; }
Test Cases
Test Results
Input
0x01F0
Expected Output
31