Posts

Showing posts with the label hex

printf() formatting for hex uint32_t without missing zeros. (in c89)

printf() formatting for hex uint32_t without missing zeros. (in c89) Wanted to print uint32 hex. Tried "PRIx32", looked bad to me: 967407c0 23 4481d55f ffffff52 de3cd140 2fc aa7363cf fffff40d 563270c0 2b86 So... tried this. Dirty but worked: /******************************************************************************* Print a digit in hex. *******************************************************************************/ void mpal_digit_t_print_hex( mpal_digit_t * input) { uint8_t p_1, p_2, p_3, p_4, p_5, p_6, p_7, p_8; p_1 = (uint8_t)(((*input) << 0) >> 28); p_2 = (uint8_t)(((*input) << 4) >> 28); p_3 = (uint8_t)(((*input) << 8) >> 28); p_4 = (uint8_t)(((*input) << 12) >> 28); p_5 = (uint8_t)(((*input) << 16) >> 28); p_6 = (uint8_t)(((*input) << 20) >> 28); p_7 = (uint8_t)(((*input) << 24) >> 28); p_8 = (uint8_t)(((*input) << 28) ...