Re: BUG #12885: The result of casting a double to an integer depends on the database version - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date
Msg-id 13096.1427204266@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #12885: The result of casting a double to an integer depends on the database version  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: BUG #12885: The result of casting a double to an integer depends on the database version  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-bugs
Michael Paquier <michael.paquier@gmail.com> writes:
> On Mon, Mar 23, 2015 at 8:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Look for something about setting the IEEE float rounding mode.  "Round to
>> nearest even" is standard in most places, but it would not astonish me
>> to hear that Microsoft got that wrong.

> I have done more testing (done only 9.3 with MinGW and MSVC before)
> and the failure can be reproduced on master and REL9_4_STABLE as well
> because visibly with MSVC 2010 the version of rint used is the one of
> src/port, which is defined like that:
> return (x >= 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
> For example by passing 2.5, we would get 3.0, and not 2.0 (nearest
> even number). So isn't the problem here?

Hmm ... why are we using src/port's version?  rint() has been required
by POSIX for decades, surely MSVC has got it?

(IOW, I'd rather fix this by removing src/port's version than by
trying to upgrade it to full IEEE spec.)

            regards, tom lane

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pg_upgrade failure on Windows Server
Next
From: Bruce Momjian
Date:
Subject: Re: ALTER TABLE documentation or parser bug