From 44bf269ecb8fc4f32cd02eee631452ecc5afcf82 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sun, 3 Aug 2008 17:25:34 +0200 Subject: [PATCH] Rounding of numbers is now performed towards closest even integer, not odd as before. --- src/c/num_co.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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;