Comments Bradley Lucier (20 Jul 2026 21:14 UTC)
Re: Comments John Cowan (20 Jul 2026 22:40 UTC)
Re: Comments Bradley Lucier (21 Jul 2026 00:43 UTC)
Re: Comments Peter McGoron (21 Jul 2026 02:58 UTC)
Re: Comments Bradley Lucier (21 Jul 2026 20:11 UTC)
Re: Comments Peter McGoron (21 Jul 2026 14:53 UTC)
Re: Comments Bradley Lucier (21 Jul 2026 20:09 UTC)
Re: Comments Marc Feeley (21 Jul 2026 21:43 UTC)
Re: Comments Peter McGoron (22 Jul 2026 02:43 UTC)
Re: Comments Bradley J Lucier (22 Jul 2026 02:59 UTC)

Re: Comments Peter McGoron 21 Jul 2026 02:55 UTC

The `round-away` procedure in this SRFI corresponds to the `round`
procedure in C99: https://cppreference.com/c/numeric/math/round

Meanwhile, the standard `round` procedure corresponds to the `roundeven`
procedure in C23: https://port70.net/~nsz/c/c23/n3220.html#7.12.9.8
which breaks ties by rounding to even.

The purpose of adding round-away is to have conversion-to-integer
procedures that align with the functions of other languages. Although
one could implement other tie-breaking modes, I don't know of any
languages that do that.

IEEE 754-2019 standard includes procedures that are equivalent to
Scheme's truncate, floor, ceiling, round and this SRFI's round-even.
(IEEE 754 also has a "round according to current rounding mode"
procedure, which isn't applicable here.) The relevant section is copied
below:

___________________________________________

5.9 Details of operations to round a floating-point datum to integral value

Several operations round a floating-point number to an integral-valued
floating-point number in the same format.

The rounding is analogous to that specified in Clause 4, but the
rounding chooses only from among those floating-point numbers of
integral values in the format. [...]

― sourceFormat roundToIntegralTiesToEven(source)
roundToIntegralTiesToEven(x) rounds x to the nearest integral value,
with halfway cases rounding to even.

― sourceFormat roundToIntegralTowardZero(source)
roundToIntegralTowardZero(x) rounds x to an integral value toward zero.

― sourceFormat roundToIntegralTowardPositive(source)
roundToIntegralTowardPositive(x) rounds x to an integral value toward
positive infinity.

― sourceFormat roundToIntegralTowardNegative(source)
roundToIntegralTowardNegative(x) rounds x to an integral value toward
negative infinity.

― sourceFormat roundToIntegralTiesToAway(source)
roundToIntegralTiesToAway(x) rounds x to the nearest integral value,
with halfway cases rounding away from zero.