I\'d like to write a function, in C, which takes the MSB of uint8_t, and if it\'s set, returns 0xFF and if not 0x00. In short, which retur
uint8_t
0xFF
0x00
Given the declaration of your uint8_t:
uint8_t x = // MSB is either 1 or 0 if `x` depending on the signed value of `x`
A cheat that assumes 2's complement for signed integers:
return (((uint16_t)(int8_t)x) >> 8) & 0xff;