我从计算机系统:程序员的观点中了解到,IEEE标准要求使用以下64位二进制格式表示双精度浮点数:
+无穷大表示为具有以下模式的特殊值:
我认为double的完整64位应按以下顺序排列:
(一个或多个)(EXP)(FRAC)
所以我编写以下C代码来验证它:
//Check the infinity
double x1 = (double)0x7ff0000000000000; // This should be the +infinity
double x2 = (double)0x7ff0000000000001; // Note the extra ending 1, x2 should be NaN
printf("\nx1 = %f, x2 = %f sizeof(double) = %d", x1,x2, sizeof(x2));
if (x1 == x2)
printf("\nx1 == x2");
else
printf("\nx1 != x2");
Run Code Online (Sandbox Code Playgroud)
但结果是:
x1 = 9218868437227405300.000000, x2 = 9218868437227405300.000000 sizeof(double) = 8
x1 == x2
Run Code Online (Sandbox Code Playgroud)
为什么数字是有效数字而不是无穷大错误?
为什么x1 == …
我正在用 Eclipse + CDT + MinGW 编写一些 C 代码。
编译输出总是显示:
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o Math.o "..\\Math.c"
Run Code Online (Sandbox Code Playgroud)
如何更改命令行参数,例如 -O0、-Wall?
(我是 Eclipse IDE 的新手。)