CLearn/Chapter_3/3_7_1_floaterr.c

15 lines
304 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 演示浮点数舍入错误 */
#include <stdio.h>
int main(void)
{
float a,b;
b = 2.0e20 + 1.0;
a = b - 2.0e20;
printf("%f \n", a);
return 0;
}
//如果是当前版本 GCC通常结果为 4008175468544.000000
//这个结果表明编译器实现遵循ISO/IEC/IEEE 60559:2011