Re: rint() replacement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: rint() replacement
Дата
Msg-id 4254.1052540967@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: rint() replacement  ("Dann Corbit" <DCorbit@connx.com>)
Ответы Re: rint() replacement  (Kurt Roeckx <Q@ping.be>)
Список pgsql-hackers
"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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Win32 runs configure and gmake test
Следующее
От: Joe Conway
Дата:
Сообщение: Re: Beta July 1