From 08ead2686aa9030a2bd94fa009062781f23725b8 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 15 May 2021 08:07:20 -0700 Subject: [PATCH] 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. --- lib/gvc/gvdevice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.40.0