]> granicus.if.org Git - graphviz/commitdiff
broaden 0 check in gvprintdouble
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 15 May 2021 15:07:20 +0000 (08:07 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 27 May 2021 03:26:36 +0000 (20:26 -0700)
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.

lib/gvc/gvdevice.c

index c811a7d71b1ac50d515dfd06a73bb3c7ea799bc8..a65d0e5a1547102e985d73557e0234a7ade72406 100644 (file)
@@ -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;