From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Upgrade src/port/rint.c to be POSIX-compliant.
Date: Wed, 25 Mar 2015 19:54:34 +0000
Message-ID: <E1YarNq-0005rm-Hx@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
Upgrade src/port/rint.c to be POSIX-compliant.
The POSIX spec says that rint() rounds halfway cases to nearest even.
Our substitute implementation failed to do that, rather rounding halfway
cases away from zero; and it also got some other cases (such as minus
zero) wrong. This led to observable cross-platform differences, as
reported in bug #12885 from Rich Schaaf; in particular, casting from
float to int didn't honor round-to-nearest-even on builds using rint.c.
Implement something that attempts to cover all cases per spec, and add
some simple regression tests so that we'll notice if any platforms still
get this wrong.
Although this is a bug fix, no back-patch, as a behavioral change in
the back branches was agreed not to be a good idea.
Pedro Gimeno Fortea, reviewed by Michael Paquier and myself
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/06bf0dd6e354c765403d1331cc9896b360754521
Modified Files
--------------
src/port/rint.c | 81 +++++++++++++++++++-
src/test/regress/expected/int2.out | 20 +++++
src/test/regress/expected/int4.out | 20 +++++
.../regress/expected/int8-exp-three-digits.out | 20 +++++
src/test/regress/expected/int8.out | 20 +++++
src/test/regress/sql/int2.sql | 10 +++
src/test/regress/sql/int4.sql | 10 +++
src/test/regress/sql/int8.sql | 10 +++
8 files changed, 190 insertions(+), 1 deletion(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Upgrade src/port/rint.c to be POSIX-compliant.
In-Reply-To: <E1YarNq-0005rm-Hx@gemulon.postgresql.org>
References: <E1YarNq-0005rm-Hx@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox