Re: round behavior differs between 8.1.5 and 8.3.7

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Morton <morton2002(at)gmail(dot)com>
Cc: Adrian Klaver <aklaver(at)comcast(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: round behavior differs between 8.1.5 and 8.3.7
Date: 2009-04-21 19:00:17
Message-ID: 9757.1240340417@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert Morton <morton2002(at)gmail(dot)com> writes:
> Perhaps there are platform differences, since the version I am using was
> built with Microsoft Visual Studio:

Ah, now you tell us.

round(float8) just calls the platform's rint() function. At least on
platforms that have rint(), which maybe Windows doesn't. In that case
it's going to come down to src/port/rint.c, which is not particularly
careful about the exactly-0.5 case. I think fully-standards-conformant
versions of rint() are probably going to use a "round to nearest even
integer" rule in such cases. But by and large, float8 arithmetic *is*
going to have platform-specific behaviors; you're living in a fantasy
world if you think otherwise.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2009-04-21 19:05:40 Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Previous Message Chris Worley 2009-04-21 18:15:45 Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'