From: Michael Beck Date: Thu, 3 Jul 2003 09:45:08 +0000 (+0000) Subject: integer floating point values will be printed witha .0 appended X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=6b74d7d8bb06a79c659f229e8024a5cece0b9126;p=libfirm integer floating point values will be printed witha .0 appended [r1437] --- diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c index 0a80b5973..df890d80e 100644 --- a/ir/tv/fltcalc.c +++ b/ir/tv/fltcalc.c @@ -170,11 +170,24 @@ int fc_comp(const void *a, const void *b) char *fc_print_dec(const void *a, char *buf, int buflen) { + int n; + #ifdef USE_LONG_DOUBLE - snprintf(buf, buflen, "%1.30Lg", CAST_IN(a)); + n = snprintf(buf, buflen, "%1.30Lg", CAST_IN(a)); #else - snprintf(buf, buflen, "%1.30g", CAST_IN(a)); + n = snprintf(buf, buflen, "%1.30g", CAST_IN(a)); #endif + + if (n > -1 && n < buflen) { + /* + * for some backends we always want to present 0 as 0.0 + * as I could not find the best format to express this, add + * a .0 explicitely if not found + */ + if (NULL == strrchr(buf, '.')) + strncat(buf, ".0", buflen); + } + return buf; }