Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ya3eG-0000V8-4T for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Mar 2015 14:48:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Ya3eF-0006Il-Dl for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Mar 2015 14:48:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ya3eD-0006ER-40 for pgsql-bugs@postgresql.org; Mon, 23 Mar 2015 14:48:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ya3e9-00038J-UU for pgsql-bugs@postgresql.org; Mon, 23 Mar 2015 14:48:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t2NEm3E3032479; Mon, 23 Mar 2015 10:48:03 -0400 From: Tom Lane 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 In-reply-to: <20150320194337.2573.72944@wrigleys.postgresql.org> References: <20150320194337.2573.72944@wrigleys.postgresql.org> Comments: In-reply-to rschaaf@commoninf.com message dated "Fri, 20 Mar 2015 19:43:37 -0000" Date: Mon, 23 Mar 2015 10:48:03 -0400 Message-ID: <32478.1427122083@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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