From: Jim Evins Date: Mon, 3 May 2010 01:39:22 +0000 (-0400) Subject: Do a better job of rounding in lgl_str_format_fraction(). X-Git-Tag: glabels-2_3_0~43 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7d926a37cc8956753d610140fc301b845e3a7de9;p=glabels Do a better job of rounding in lgl_str_format_fraction(). When a number is determined to be "close enough" to being an integer, don't just simply cast the number to get the integer value. --- diff --git a/libglabels/str.c b/libglabels/str.c index a3236275..b0b71452 100644 --- a/libglabels/str.c +++ b/libglabels/str.c @@ -249,7 +249,7 @@ lgl_str_format_fraction (gdouble x) } if ( denom[i] == 1.0 ) { /* Simple integer. */ - return g_strdup_printf ("%d", (gint)x); + return g_strdup_printf ("%.0g", x); } n = (gint)( x * denom[i] + 0.5 ); d = (gint)denom[i];