[glabels] Do a better job of rounding in lgl_str_format_fraction().



commit 7d926a37cc8956753d610140fc301b845e3a7de9
Author: Jim Evins <evins snaught com>
Date:   Sun May 2 21:39:22 2010 -0400

    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.

 libglabels/str.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/libglabels/str.c b/libglabels/str.c
index a323627..b0b7145 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];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]