ref: 46f9c39bf931494b7e2e3bdfbcdb17dae6ea599a
parent: 7bc888ae5c8b31f7ccf657a7184b7b3957d48fba
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Dec 4 02:58:47 EST 2020
more correct round()
--- a/common.h
+++ b/common.h
@@ -18,8 +18,10 @@
static double
round(double d)
{
- modf(d > 0 ? d+1.0 : d-1.0, &d);
- return d;
+ double f = modf(d, &d);
+ if(f == 0.0 || d == 0.0)
+ return d;
+ return d > 0 ? d+1 : d-1;
}
#else
#include <assert.h>