Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1EEE4133616B for ; Thu, 10 Feb 2011 23:23:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 80453-02-3 for ; Fri, 11 Feb 2011 03:22:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 450511337BCE for ; Thu, 10 Feb 2011 23:22:30 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p1B3MUYa013054; Thu, 10 Feb 2011 22:22:30 -0500 (EST) To: "brad" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #5880: Rounding error when copying a REAL numeric value to DOUBLE PRECISION In-reply-to: <201102102338.p1ANcupQ035423@wwwmaster.postgresql.org> References: <201102102338.p1ANcupQ035423@wwwmaster.postgresql.org> Comments: In-reply-to "brad" message dated "Thu, 10 Feb 2011 23:38:56 +0000" Date: Thu, 10 Feb 2011 22:22:30 -0500 Message-ID: <13053.1297394550@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/105 X-Sequence-Number: 29377 "brad" writes: > Steps to recreate are below. The real value is improperly rounded when > inserted into a field that is double. 94.31 is stored as 94.3099975585938 > when it is inserted into a double precision column. This is not a bug, it's just the typical behavior of float arithmetic. "94.31" doesn't have any exact equivalent in float4, so when you convert it to a form that is willing to print more decimal places, you find out that indeed the stored value wasn't quite 94.31. If this sort of thing makes you uncomfortable, probably you should be using type "numeric" instead. regards, tom lane