Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8C0F3632CE7 for ; Fri, 11 Dec 2009 12:29:35 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 76919-07-3 for ; Fri, 11 Dec 2009 16:29:24 +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 763FF633B5B for ; Fri, 11 Dec 2009 12:29:24 -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 nBBGTNwx019401; Fri, 11 Dec 2009 11:29:23 -0500 (EST) To: Michael Nacos cc: pgsql-jdbc@postgresql.org Subject: Re: real -> numeric -> real result different through jdbc In-reply-to: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com> References: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com> Comments: In-reply-to Michael Nacos message dated "Fri, 11 Dec 2009 16:05:04 +0000" Date: Fri, 11 Dec 2009 11:29:23 -0500 Message-ID: <19400.1260548963@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.803 tagged_above=-10 required=5 tests=AWL=-0.693, BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 200912/27 X-Sequence-Number: 20108 Michael Nacos writes: > what's the story here? how can the jdbc driver affect the precision of real > to numeric / numeric to real casts within PL/pgSQL functions? I seem to recall hearing that JDBC fools with the extra_float_digits setting. The "0.60000002" looks like it probably is the actual result of casting 0.6 to float4 --- remember float4 is only good to about six decimal digits. The default display of float4 rounds off at six digits, but in some contexts you don't want that rounding to happen because it might result in losing even more precision. JDBC is being conservative and taking the latter approach. regards, tom lane