"Dann Corbit" <DCorbit@connx.com> writes:
> Probably, most of the time nearbyint() is what is really wanted instead
> of rint(). The rint() function can throw an exception even when it does
> what is wanted.
The real issue here is "what is portable behavior"?
PG never changes the rounding mode, so we should always get the default,
which is round-to-nearest-even unless there have been big changes made
while I wasn't looking.
Expressing that as nearest() instead of rint() would be fine with me if
all platforms recognized nearest(). But rint() is more likely to be
portable in the real world, AFAIK.
I do have a bit of a problem with the CVS-tip version of this code: it
falls back to implementing rint() in terms of modf(). I would like to
know the justification for assuming that modf() is more portable than
rint().
> Most of the time, this is what rint() is doing if we are round to
> nearest:
> return floor(x+0.5);
I'd be happier with that as a fallback implementation ...
regards, tom lane