From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(at)enterprisedb(dot)com> |
Cc: | Peter Kovacs <maxottovonstirlitz(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: PreparedStatement rounds doubles to scale 14 during update |
Date: | 2007-10-07 22:47:24 |
Message-ID: | Pine.BSO.4.64.0710071844250.26337@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Mike C. | 2007-10-07 22:58:32 | Re: [BUGS] BUG #2856: Jdbc 4 connector running on JDK 1.6 should |
Previous Message | Kris Jurka | 2007-10-07 19:48:53 | Re: [BUGS] BUG #2856: Jdbc 4 connector running on JDK 1.6 should |