Rounding of numbers is now performed towards closest even integer, not odd as before.

This commit is contained in:
Juan Jose Garcia Ripoll 2008-08-03 17:25:34 +02:00
parent 0624a22718
commit 44bf269ecb

View file

@ -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;