pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Heikki Linnakangas <heikki@enterprisedb.com>
Cc: Peter Kovacs <maxottovonstirlitz@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement rounds doubles to scale 14 during update
Date: Sun, 7 Oct 2007 18:47:24 -0400 (EDT)
Message-ID: <Pine.BSO.4.64.0710071844250.26337@leary.csoft.net> (raw)
In-Reply-To: <46DEB80F.40008@enterprisedb.com>
References: <b6e8f2e80709050227r420d7a3cx751f819fba658854@mail.gmail.com>
	<46DE7E7A.70208@enterprisedb.com>
	<b6e8f2e80709050442s7439d8ebt345024599931400d@mail.gmail.com>
	<46DE9C1F.6030407@enterprisedb.com>
	<b6e8f2e80709050640y557f4844me0847ffbcb4297eb@mail.gmail.com>
	<46DEB80F.40008@enterprisedb.com>



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



view thread (13+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0710071844250.26337@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0710071844250.26337@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0710071844250.26337@leary.csoft.net

 · 

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-jdbc@postgresql.org
  Cc: books@ejurka.com, heikki@enterprisedb.com, maxottovonstirlitz@gmail.com
  Subject: Re: PreparedStatement rounds doubles to scale 14 during update
  In-Reply-To: <Pine.BSO.4.64.0710071844250.26337@leary.csoft.net>
  References: <b6e8f2e80709050227r420d7a3cx751f819fba658854@mail.gmail.com> <46DE7E7A.70208@enterprisedb.com> <b6e8f2e80709050442s7439d8ebt345024599931400d@mail.gmail.com> <46DE9C1F.6030407@enterprisedb.com> <b6e8f2e80709050640y557f4844me0847ffbcb4297eb@mail.gmail.com> <46DEB80F.40008@enterprisedb.com> <Pine.BSO.4.64.0710071844250.26337@leary.csoft.net>

* 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