当询问C中常见的未定义行为时,灵魂比我提到的严格别名规则更加开明. 他们在说什么?
c strict-aliasing undefined-behavior type-punning
我对以下代码的输出感到困惑:
float a = 1.32; int* b; b= &a; printf("%d", *b);
这段代码将float转换为int,但我得到的输出是:1068037571
这与计算机的IEEE 754转换功能有关吗?谢谢!
c floating-point integer type-conversion
c ×2
floating-point ×1
integer ×1
strict-aliasing ×1
type-conversion ×1
type-punning ×1
undefined-behavior ×1