pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Campbell, Greg <greg.campbell@us.michelin.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: postgresql.org@tgice.com
Cc: pgsql-odbc@postgresql.org
Subject: Re: float8 auto truncation issue in ODBC v. PGSQL
Date: Tue, 13 Jun 2006 17:02:30 -0400
Message-ID: <448F27E6.406@us.michelin.com> (raw)
In-Reply-To: <10152.1150229689@sss.pgh.pa.us>
References: <448F11E2.1020504@tgice.com>
	<10152.1150229689@sss.pgh.pa.us>

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

Attachments:

greg.campbell.vcf (text/x-vcard, 239B) download 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

view thread (7+ messages)  latest in thread

Message-ID: <448F27E6.406@us.michelin.com>
Permalink:  ../448F27E6.406@us.michelin.com/
Also on:    postgresql.org/message-id/448F27E6.406@us.michelin.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: greg.campbell@us.michelin.com, tgl@sss.pgh.pa.us, postgresql.org@tgice.com
  Subject: Re: float8 auto truncation issue in ODBC v. PGSQL
  In-Reply-To: <448F27E6.406@us.michelin.com>
  References: <448F11E2.1020504@tgice.com> <10152.1150229689@sss.pgh.pa.us> <448F27E6.406@us.michelin.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox