Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 035E39F9915 for ; Sun, 7 Oct 2007 19:47:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 19180-08 for ; Sun, 7 Oct 2007 19:47:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 8920C9F97E5 for ; Sun, 7 Oct 2007 19:47:25 -0300 (ADT) Received: (qmail 26973 invoked by uid 1112); 7 Oct 2007 22:47:24 -0000 Date: Sun, 7 Oct 2007 18:47:24 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Heikki Linnakangas cc: Peter Kovacs , pgsql-jdbc@postgresql.org Subject: Re: PreparedStatement rounds doubles to scale 14 during update In-Reply-To: <46DEB80F.40008@enterprisedb.com> Message-ID: References: <46DE7E7A.70208@enterprisedb.com> <46DE9C1F.6030407@enterprisedb.com> <46DEB80F.40008@enterprisedb.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/60 X-Sequence-Number: 17632 On Wed, 5 Sep 2007, Heikki Linnakangas wrote: > Peter Kovacs wrote: >> One last question: >> >> How come that Java double, which is an 8 byte size floating point >> number, cannot fit in PostgreSQL's double precision type, which is >> equally a floating point type and 8 bytes in size? > > Hmm. I'm not sure when the truncation happens. The value might actually > still be intact when it's converted from text representation to double, > and loses precision in the conversion from float8 to decimal. It's > possible to have a floating point value in the database that you can't > get out in text format without losing precision. Consider this for example: > > postgres=# SELECT > '6.118992224252588'::float8, > '6.11899222425259'::float8, > '6.11899222425259'::float8 = '6.118992224252588'::float8; > float8 | float8 | ?column? > ------------------+------------------+---------- > 6.11899222425259 | 6.11899222425259 | f > (1 row) > > Both values are rounded to the same value on output, but if you compare > them, they're actually not equal. > Actually you'll see different behavior with "SET extra_float_digits=2". Is there a reason we shouldn't set this when we create a connection? Kris Jurka