X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2E71FD1B53E for ; Tue, 28 Oct 2003 16:27:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23009-02 for ; Tue, 28 Oct 2003 12:27:07 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C07BED1B509 for ; Tue, 28 Oct 2003 12:26:51 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h9SGQNit023858; Tue, 28 Oct 2003 11:26:23 -0500 (EST) To: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" Cc: pgsql-sql@postgresql.org Subject: Re: numeric and float converts to int differently? In-reply-to: <072c01c39d65$65f83950$0403a8c0@fejleszt4> References: <072c01c39d65$65f83950$0403a8c0@fejleszt4> Comments: In-reply-to "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" message dated "Tue, 28 Oct 2003 16:08:51 +0100" Date: Tue, 28 Oct 2003 11:26:22 -0500 Message-ID: <23857.1067358382@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/367 X-Sequence-Number: 15767 "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: > QUESTION 1: Is it intentional that converting 0.5 to int4 > - from numeric: rounds *away from* zero > - from float: rounds *towards* zero (tried float4 and float8 too)? Numeric currently rounds away from zero. We cannot guarantee to make it work the same as float, because float's rounding behavior is platform-dependent. A common but not universal behavior is "round to nearest even integer". See the recent thread about the round() function (I forget which list it was in, but it was within the past week). > QUESTION 2: Is it safe to assume it won't change (haven't changed) in the > upcoming versions? Numeric's behavior hasn't changed as of 7.4beta5. I do not have a crystal ball to predict whether we might change it in the future. I doubt we will ever try to override the platform behavior for float. regards, tom lane