From eac072593c69519fc2c01f5ef6fd00173ff23b18 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Tue, 26 May 2009 23:23:39 +0000 Subject: [PATCH] Nicer formatting of '.0' git-svn-id: http://picoc.googlecode.com/svn/trunk@287 21eae674-98b7-11dd-bd71-f92a316d2d60 --- clibrary.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/clibrary.c b/clibrary.c index bc0230d..2366ab8 100644 --- a/clibrary.c +++ b/clibrary.c @@ -106,9 +106,15 @@ void PrintFP(double Num, struct OutputStream *Stream) Num /= pow(10.0, Exponent); PrintInt((int)Num, Stream); PrintCh('.', Stream); - for (Num = (Num - (int)Num) * 10; abs(Num) >= 1e-7; Num = (Num - (int)(Num + 1e-7)) * 10) - PrintCh('0' + (int)(Num + 1e-7), Stream); - + Num = (Num - (int)Num) * 10; + if (abs(Num) >= 1e-7) + { + for (; abs(Num) >= 1e-7; Num = (Num - (int)(Num + 1e-7)) * 10) + PrintCh('0' + (int)(Num + 1e-7), Stream); + } + else + PrintCh('0', Stream); + if (Exponent != 0) { PrintCh('e', Stream);