mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-15 17:30:37 -07:00
Fixed rounding towards even numbers in ROUND.
This commit is contained in:
parent
ea4a5f3165
commit
29fa06188a
1 changed files with 6 additions and 10 deletions
|
|
@ -620,11 +620,9 @@ static double
|
|||
round_double(double d)
|
||||
{
|
||||
if (d >= 0) {
|
||||
double q = floor(d + 0.5);
|
||||
d -= q;
|
||||
if (d == -0.5) {
|
||||
double x = q / 10;
|
||||
int i = (int)(10 * (x - floor(x)));
|
||||
double q = floor(d += 0.5);
|
||||
if (q == d) {
|
||||
int i = (int)fmod(q, 10);
|
||||
if (i & 1) {
|
||||
return q-1;
|
||||
}
|
||||
|
|
@ -640,11 +638,9 @@ static long double
|
|||
round_long_double(long double d)
|
||||
{
|
||||
if (d >= 0) {
|
||||
long double q = floorl(d + 0.5);
|
||||
d -= q;
|
||||
if (d == -0.5) {
|
||||
long double x = q / 10;
|
||||
int i = (int)(10 * (x - floorl(x)));
|
||||
long double q = floorl(d += 0.5);
|
||||
if (q == d) {
|
||||
int i = (int)fmodl(q, 10);
|
||||
if (i & 1) {
|
||||
return q-1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue