From fe2322c9e271b1d277234f0b8b1ceaafe1fa9ccc Mon Sep 17 00:00:00 2001 From: zeekling Date: Tue, 2 Nov 2021 23:07:58 +0800 Subject: [PATCH] add showf_pt.c --- chapter3/showf_pt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 chapter3/showf_pt.c diff --git a/chapter3/showf_pt.c b/chapter3/showf_pt.c new file mode 100644 index 0000000..c898e5b --- /dev/null +++ b/chapter3/showf_pt.c @@ -0,0 +1,17 @@ +#include + +int main() +{ + 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 hexadcimal, powers of 2 notation\n", aboat); + printf("%f can be written %e\n", abet, abet); + // %LF 可能会存在精度丢失的问题 + printf("%LF can be written %Le\n", dip, dip); + + return 0; +}