#include <stdio.h>
int main(void) {
double x = 0.12345678901234567890123456789;
printf("%0.16f\n", x);
return 0;
};
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我x
用文字初始化太大而不能用IEEE 754双精度表示.在我的PC上使用gcc 4.9.2它运行良好.文字四舍五入到最接近double的值.我想知道在这种情况下幕后发生了什么(在编译器级别)?这种行为取决于平台吗?这合法吗?