我们如何在 C 中打印浮点值的编码?
我知道我可以使用 %A
,但这不是我想要的格式。
例如,如果我的值为 1.3416407,我想打印“0x3FABBAE2”,而不是“0X1.5775C4P+0”。
最佳答案
您可以使用 union ,例如
#include <stdio.h>
#include <stdint.h>
union {
float f;
uint32_t i;
} u;
u.f = 1.3416407f;
printf("%#X\n", u.i);
关于c - 如何显示浮点值的编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17664523/