cyclone/scheme
Yorick Hardy 4bbceeb4d6 round half-integers to even instead of away from zero
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;
  }
2024-02-01 22:25:47 +02:00
..
cyclone Update year 2024-01-02 18:03:53 -08:00
base.sld round half-integers to even instead of away from zero 2024-02-01 22:25:47 +02:00
case-lambda.sld Added header comment block. 2016-02-14 22:35:04 -05:00
char.sld Use fast version of member 2016-10-15 18:19:18 -04:00
complex.sld Build-out make-rectangular 2018-05-10 13:24:24 -04:00
cxr.sld Fix (scheme cxr) definitions 2019-12-01 20:53:21 -06:00
eval.sld Issue #489 - Guarantee order of eval begin exprs 2022-07-21 21:41:47 -04:00
file.sld Added header comment block. 2016-02-14 22:35:04 -05:00
inexact.sld Issue #376 - Support for two-argument atan 2020-05-20 22:26:07 -04:00
lazy.sld Updated force to recursively force promises. 2020-09-15 12:42:02 -04:00
load.sld Allow (load) to read source location information 2020-07-23 15:52:36 -04:00
process-context.sld Set immutable flag 2019-05-01 17:41:47 -04:00
read.sld Issue #517 - Raise error when reading invalid number 2023-12-05 18:14:52 -08:00
repl.sld Flush current-output-port after writing prompt to it 2021-08-03 11:36:14 +02:00
time.sld Cleaned-up timing code 2021-03-05 22:57:33 -03:00
write.sld Added aliases for missing write functions 2016-09-27 18:01:40 -04:00