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 07AA99FA5C8 for ; Wed, 14 Jun 2006 15:45:13 -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 56870-04 for ; Wed, 14 Jun 2006 15:45:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 5477F9FA3D7 for ; Wed, 14 Jun 2006 15:45:03 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FqaMB-0007Zt-It for pgsql-odbc@postgresql.org; Wed, 14 Jun 2006 20:44:48 +0200 Received: from 83.145.96.118 ([83.145.96.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Jun 2006 20:44:47 +0200 Received: from Marc.Herbert by 83.145.96.118 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Jun 2006 20:44:47 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-odbc@postgresql.org From: Marc Herbert Subject: Re: float8 auto truncation issue in ODBC v. PGSQL Date: Wed, 14 Jun 2006 20:44:24 +0200 Lines: 34 Message-ID: References: <448F11E2.1020504@tgice.com> <10152.1150229689@sss.pgh.pa.us> <448F27E6.406@us.michelin.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 83.145.96.118 User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:09UtlHEXDj86X7HnUMcKeGDgvEw= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/103 X-Sequence-Number: 7851 "Campbell, Greg" writes: > I've disassociated floats and exactness, that is floating point > representations and exact matches do not seem to go together. The issue is that "float" types actually means fractions encoded in base 2 for efficiency reasons. Almost every time you go back and forth between base 2 and base 10 you have to round, there is no exact mapping between those two spaces. For instance you can not write 1/3 (one third) in base 10 whereas you can in base 3 using just a couple of digits (it's just "0.1") > 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. Actually on today's hardware I thought it was hard to find anything else than IEEE754 32 and 64 bits floats, standardized across all platforms, and 32 bits values being a subset of 64 bits. So that does not look like "many different ways" to me. Could you detail? > Between a value > on the server and a value on the client a difference out in the 15th > decimal place hardly seems surprising. Whether conversions and roundings happen on the server on or the client does not seem to change the problem much IMHO.