diff --git a/src/c/num_co.d b/src/c/num_co.d index a5acae0ae..0d21740f9 100644 --- a/src/c/num_co.d +++ b/src/c/num_co.d @@ -780,11 +780,11 @@ round_double(double d) if (d >= 0) { double q = floor(d + 0.5); d -= q; - if (d == 0.5) { + if (d == -0.5) { double x = q / 10; int i = (int)(10 * (x - floor(x))); if (i & 1) { - return q+1; + return q-1; } } return q; @@ -800,11 +800,11 @@ round_long_double(long double d) if (d >= 0) { long double q = floorl(d + 0.5); d -= q; - if (d == 0.5) { + if (d == -0.5) { long double x = q / 10; int i = (int)(10 * (x - floorl(x))); if (i & 1) { - return q+1; + return q-1; } } return q;