commit 8d0d5058dc898a24c7a36fc5dff11f25e0b0221e Author: John Denker Date: Thu Jul 8 19:45:01 2021 -0700 repair go_fake_floor() so that fuzzy rounding works for negative (not just positive) inputs diff --git a/goffice/math/go-math.c b/goffice/math/go-math.c index 6b0c8a23..ddd9434e 100644 --- a/goffice/math/go-math.c +++ b/goffice/math/go-math.c @@ -240,6 +240,16 @@ go_d2d (double x) return *px; } +/*** + ++ This function behaves like gnumeric.int() + and "almost" like POSIX.floor(), + i.e. it always rounds toward minus infinity. + + Like all gnumeric rounding functions and unlike POSIX, + it performs fuzzy rounding. + + -- Despite the name, it does not behave like gnumeric.floor(). + ***/ double go_fake_floor (double x) { @@ -248,9 +258,8 @@ go_fake_floor (double x) if (x == floor (x)) return x; - return (x >= 0) - ? floor (go_add_epsilon (x)) - : floor (go_sub_epsilon (x)); +/* if x is very near an integer, use the integer instead: */ + return floor (go_add_epsilon (x)); } double