mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-24 21:41:29 -08:00
Rounding of numbers is now performed towards closest even integer, not odd as before.
This commit is contained in:
parent
0624a22718
commit
44bf269ecb
1 changed files with 4 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue