[cairo-commit] src/cairo-output-stream.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Oct 30 23:42:09 PDT 2007


 src/cairo-output-stream.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8297daff896ca9d803959edb3c1955977594fab9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 31 02:41:33 2007 -0400

    [cairo-output-stream] Write out floats to 18 digits after decimal point
    
    We write floats using %f as the scientific format used by smarter %g is
    invalid in PS/PDF.  %f however by default rounds to five digits after
    decimal point.  This was causing precision loss and making the newly
    added degenerate-pen test fail for PDF.  We now print up to 18 digits
    which is as many bits doubles can accomodate.  We can be smarter, but
    that's for another commit.

diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 5bce0e3..6d9c733 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -236,7 +236,7 @@ _cairo_dtostr (char *buffer, size_t size, double d)
     if (d == 0.0)
 	d = 0.0;
 
-    snprintf (buffer, size, "%f", d);
+    snprintf (buffer, size, "%.18f", d);
 
     locale_data = localeconv ();
     decimal_point = locale_data->decimal_point;


More information about the cairo-commit mailing list