|
楼主 |
发表于 2022-4-27 22:08:11
|
显示全部楼层
/* showf_pt.c -- 以两种方式显示float类型的值 */
#include <stdio.h>
int main(void)
{
float aboat = 32000.0;
double abet = 2.14e9;
long double dip = 5.32e-5;
printf("%f can be written %e\n", aboat, aboat);
// 下一行要求编译器支持C99或其中的相关特性
printf("\n 以下三行编译器不同,输出也将不同!!!\n");
printf("And it's %a in hexadecimal, powers of 2 notation\n",
aboat);
printf("%f can be written %e\n",
abet, abet);
printf("%Lf can be written %Le\n",
dip, dip);
return 0;
}
/*
code blocks 20.03输出 :
32000.000000 can be written 3.200000e+004
以下三行编译器不同,输出也将不同!!!
And it's 0x1.f40000p+14 in hexadecimal, powers of 2 notation
2140000000.000000 can be written 2.140000e+009
0.000000 can be written 1.133023e-317
Process returned 0 (0x0) execution time : 0.462 s
Press any key to continue.
----------------------------------------------------
dev-cpp-6.7.5 输出 :
32000.000000 can be written 3.200000e+04
以下三行编译器不同,输出也将不同!!!
And it's 0xf.ap+11 in hexadecimal, powers of 2 notation
2140000000.000000 can be written 2.140000e+09
0.000053 can be written 5.320000e-05
--------------------------------
Process exited after 0.955 seconds with return value 0
请按任意键继续. . .
正确输出 :(这是我在一个C语言网站上用在线编译输出的)
32000.000000 can be written 3.200000e+04
以下三行编译器不同,输出也将不同!!!
And it's 0x1.f4p+14 in hexadecimal, powers of 2 notation
2140000000.000000 can be written 2.140000e+09
0.000053 can be written 5.320000e-05
*/ |
|