From b9df205e6ad83e83864fcbfcf7f4080e0544d965 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Tue, 26 May 2009 22:31:42 +0000 Subject: [PATCH] Fixed a bug in floating point printing git-svn-id: http://picoc.googlecode.com/svn/trunk@285 21eae674-98b7-11dd-bd71-f92a316d2d60 --- clibrary.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clibrary.c b/clibrary.c index 17f6d3c..312cff4 100644 --- a/clibrary.c +++ b/clibrary.c @@ -106,10 +106,10 @@ void PrintFP(double Num, struct OutputStream *Stream) Num /= pow(10.0, Exponent); PrintInt((int)Num, Stream); PrintCh('.', Stream); - for (Num -= (int)Num; Num != 0.0; Num *= 10.0) - PrintCh('0' + (int)Num, 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); - if (Exponent) + if (Exponent != 0) { PrintCh('e', Stream); PrintInt(Exponent, Stream);