projects
/
mit-scheme.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
84b1f57
)
Fix flonum case of ROUND to use IEEE round-to-even, per the R5RS.
author
Taylor R Campbell
<campbell@mumble.net>
Fri, 13 Nov 2009 03:48:28 +0000
(22:48 -0500)
committer
Taylor R Campbell
<campbell@mumble.net>
Fri, 13 Nov 2009 03:48:28 +0000
(22:48 -0500)
src/microcode/artutl.c
patch
|
blob
|
history
diff --git
a/src/microcode/artutl.c
b/src/microcode/artutl.c
index cd6addc5fccdb621df05c75e3d22ee2bf61a97d7..9c4ed75440c4189103e54bcc2e14bda89ceca1d0 100644
(file)
--- a/
src/microcode/artutl.c
+++ b/
src/microcode/artutl.c
@@
-126,7
+126,15
@@
double_truncate (double x)
double
double_round (double x)
{
- return (double_truncate ((x < 0) ? (x - 0.5) : (x + 0.5)));
+ double integral;
+ double fractional = (fabs (modf (x, (&integral))));
+
+ if ((fractional == 0.5)
+ ? ((fmod (integral, 2.0)) == 0.0)
+ : (! (0.5 < fractional)))
+ return (integral);
+ else
+ return (integral + (copysign (x, 1.0)));
}
\f
/* Conversions between Scheme types and Scheme types. */