From e2db38c881f2e7355face4f0c0a1b2735442428d Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Fri, 17 Dec 2021 23:56:25 +0100 Subject: [PATCH] statement reordering for faster execution in my_round() --- src/actions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions.c b/src/actions.c index 735e3409..470ea79a 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2298,11 +2298,11 @@ int text_bbox(const char *str,double xscale, double yscale, return 1; } -/* does not exist in C89 */ +/* round() does not exist in C89 */ double my_round(double a) { /* return 0.0 or -0.0 if a == 0.0 or -0.0 */ - return (a == 0.0) ? a : (a > 0.0) ? floor(a + 0.5) : ceil(a - 0.5); + return (a > 0.0) ? floor(a + 0.5) : (a < 0.0) ? ceil(a - 0.5) : a; } int place_text(int draw_text, double mx, double my)