From: Matthew Fernandez Date: Sat, 15 May 2021 15:07:20 +0000 (-0700) Subject: broaden 0 check in gvprintdouble X-Git-Tag: 2.47.3~32^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08ead2686aa9030a2bd94fa009062781f23725b8;p=graphviz broaden 0 check in gvprintdouble The 0 path in this function is, as the comment says, to avoid printing confusing numbers like -0.00. However, the remainder of the function prints the number to 2 decimal places. So actually any number that *rounds* to -0.00 is going to come out this way. To avoid this, we can expand the cases where we take an early exit. This is also a minor performance speed up in these cases, as the 0 path is faster than the common path. --- diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index c811a7d71..a65d0e5a1 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -545,7 +545,7 @@ static void gv_trim_zeros(char* buf) void gvprintdouble(GVJ_t * job, double num) { // Prevents values like -0 - if (num > -0.00000001 && num < 0.00000001) + if (num > -0.005 && num < 0.005) { gvwrite(job, "0", 1); return;