mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
This changes the behaviour to match r7rs (round x) instead of C round(x). An answer to https://stackoverflow.com/questions/32746523/ieee-754-compliant-round-half-to-even suggests using remainder(). The following will work if FE_TONEAREST is defined, but C11 requires FE_TONEAREST to be defined if and only if the implemenetation supports it in fegetround() and fesetround() [Draft N1570]. On the other hand, remainder() must be defined. C23 will have roundeven(), but this is not yet available on all platforms. The behaviour of remainder is described in Draft N1570, page 254, footnote 239. Alternative implementation: double round_to_nearest_even(double x) { #pragma STDC FENV_ACCESS ON int mode; double nearest; mode = fegetround(); fesetround(FE_TONEAREST); nearest = nearbyint(x); fesetround(mode); #pragma STDC FENV_ACCESS OFF return nearest; } |
||
---|---|---|
.. | ||
cyclone | ||
base.sld | ||
case-lambda.sld | ||
char.sld | ||
complex.sld | ||
cxr.sld | ||
eval.sld | ||
file.sld | ||
inexact.sld | ||
lazy.sld | ||
load.sld | ||
process-context.sld | ||
read.sld | ||
repl.sld | ||
time.sld | ||
write.sld |