X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 61C329FA13E for ; Tue, 13 Jun 2006 18:02:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 27089-06 for ; Tue, 13 Jun 2006 18:02:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from gk-us2.us.michelin.com (gk-us2.michelin.com [156.65.14.19]) by postgresql.org (Postfix) with ESMTP id 93EAA9F9316 for ; Tue, 13 Jun 2006 18:02:41 -0300 (ADT) Received: from oncpfxp4-out.onc.michelin.com (unverified [10.21.4.32]) by gk-us2.us.michelin.com (Clearswift SMTPRS 5.1.7) with ESMTP id for ; Tue, 13 Jun 2006 17:01:40 -0400 Received: from ONCMH1.onc.michelin.com (ONCMH1.onc.michelin.com [156.65.124.40]) by oncpfxp4-out.onc.michelin.com (Postfix) with ESMTP id 38CFF1A4AB for ; Tue, 13 Jun 2006 17:02:35 -0400 (EDT) Received: from oncmtap1.onc.michelin.com by oncmh1.onc.michelin.com with ESMTP for pgsql-odbc@postgresql.org; Tue, 13 Jun 2006 17:02:34 -0400 Received: from oncems01.onc.michelin.com ([156.65.125.150]) by oncmtap1.onc.michelin.com (Netscape Messaging Server 4.15) with ESMTP id J0TH4A00.I9N for ; Tue, 13 Jun 2006 17:02:34 -0400 Received: from [10.43.12.183] (unverified) by oncems01.onc.michelin.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Tue, 13 Jun 2006 17:02:33 -0400 Message-Id: <448F27E6.406@us.michelin.com> Date: Tue, 13 Jun 2006 17:02:30 -0400 From: "Campbell, Greg" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane , postgresql.org@tgice.com CC: pgsql-odbc@postgresql.org Subject: Re: float8 auto truncation issue in ODBC v. PGSQL References: <448F11E2.1020504@tgice.com> <10152.1150229689@sss.pgh.pa.us> In-Reply-To: <10152.1150229689@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------000909070806060603080607" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/87 X-Sequence-Number: 7835 This is a multi-part message in MIME format. --------------000909070806060603080607 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I've disassociated floats and exactness, that is floating point representations and exact matches do not seem to go together. The idea was made more profound when I started looking into the multitude of options in representing a float in 16, 32 or 64 bits. There are so many different ways to allocate bits for the number, and bits for the exponent, leading to radically different precisions. Between a value on the server and a value on the client a difference out in the 15th decimal place hardly seems surprising. That float_extra_digits is a cool thing to know. Tom Lane wrote: > postgresql.org@tgice.com writes: > >>When I use my own ODBC SQL client to select the same value from my >>Postgres 8.0 database, I get the same thing: >> 1.0475000000000001 > > >>*However*, and here's the troubling part, when I select the exact same >>value using psql (and I have reason to believe the same thing is going >>on inside pl/pgsql functions), the value that comes out is: >> 1.0475 > > > By default, the float8 output routine prints a digit or so less than it > could, precisely to avoid that sort of unsightly result. You can fool > with float_extra_digits (I think that's the right name, check the docs) > if you need to adjust this behavior. > > This would only matter within a plpgsql function if you are doing > something that forces the binary value to be converted to text. Which, > if you're doing tense float computation, you probably don't want to have > happen at all. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster --------------000909070806060603080607 Content-Type: text/x-vcard; charset=utf-8; name="greg.campbell.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="greg.campbell.vcf" begin:vcard fn:Greg Campbell n:Campbell;Greg org:Michelin North America - US5 Lexington;ENG-ASE email;internet:greg.campbell@us.michelin.com title:ASE Systems Engineer tel;work:803-951-5561/x75561 x-mozilla-html:FALSE version:2.1 end:vcard --------------000909070806060603080607--