From: Tom Lane <tgl@sss.pgh.pa.us>
To: rschaaf@commoninf.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date: Mon, 23 Mar 2015 10:48:03 -0400
Message-ID: <32478.1427122083@sss.pgh.pa.us> (raw)
In-Reply-To: <20150320194337.2573.72944@wrigleys.postgresql.org>
References: <20150320194337.2573.72944@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
rschaaf@commoninf.com writes:
> The result returned by the following query appears to depend on the
> PostgreSQL database version.
> The query is:
> select column1 AS double_value, cast(column1 AS INT) AS int_value
> from (VALUES (-2.5::double precision),
> (-1.5::double precision),
> (-0.5::double precision),
> (0.5::double precision),
> (1.5::double precision),
> (2.5::double precision)) t;
> In PostgreSQL 9.3.5, the query returns:
> double_value, int_value
> -2.5, -3
> -1.5, -2
> -0.5, -1
> 0.5, 1
> 1.5, 2
> 2.5, 3
> PostgreSQL 9.4.1, the query returns:
> -2.5, -2
> -1.5, -2
> -0.5, 0
> 0.5, 0
> 1.5, 2
> 2.5, 2
FWIW, I get the latter behavior (round to nearest even) in all release
branches, and I would say that one is correct. Not real sure why your
9.3 installation is misbehaving.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rschaaf@commoninf.com
Subject: Re: BUG #12885: The result of casting a double to an integer depends on the database version
In-Reply-To: <32478.1427122083@sss.pgh.pa.us>
References: <20150320194337.2573.72944@wrigleys.postgresql.org> <32478.1427122083@sss.pgh.pa.us>
* 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