#include<stdio.h> int D12_1_showf_pt(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("And it's %a in hexademical,power 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; }
運行結果:
git
上溢
無窮大
的值,printf
該值的時候會顯示inf
或infinity
。下溢
低於正常值
的浮點值。#include<stdio.h> int D12_2_Floaterr(void) { float a, b; b = 2.0e20 + 1.0; a = b - 2.0e20; printf("%f\n", a); return 0; }
運行顯示:
github