From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Dann Corbit" <DCorbit(at)connx(dot)com> |
Cc: | "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Subject: | Re: rint() replacement |
Date: | 2003-05-10 04:29:27 |
Message-ID: | 4254.1052540967@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Dann Corbit" <DCorbit(at)connx(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-05-10 04:47:26 | Re: Beta July 1 |
Previous Message | Joe Conway | 2003-05-10 04:29:14 | Re: Beta July 1 |