Re: Precision problems with storage of float/double

From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: John Smith <nukemd(at)hotmail(dot)com>
Cc: "pgsql-odbc(at)postgresql(dot)org" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Precision problems with storage of float/double
Date: 2014-06-17 03:24:51
Message-ID: 539FB503.3090103@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

(2014/06/16 1:51), John Smith wrote:
> Hi,
>
> I have found that floats and doubles that I save to the database with the ODBC driver may lose precision. The exact bit pattern of my double/float is not what is actually saved in the database. This causes difficulties in situations where you need to compare current record contents with the actual data that was inserted.
>
> It appears to be related to conversion from the double/float to text before it is sent to the database.
>
> I made a simple patch that appears to fix the issue (by adding more decimal digits in the string conversion), and a test case that tests the issue.

Thanks.

As far as I examined, 9 decimal digits for 32-bit reals and 17 decimal
digits for 64-bit doubles are sufficient to guarantee the complete
recovery.
Is it OK to change decimal digits in your patch to those ones?

Hmm I noticed that server's output should be changed in addition
to this change. The setting of extra_float_digits should be changed
from 2 to 3.

regards,
Hiroshi Inoue

--
I am using the free version of SPAMfighter.
SPAMfighter has removed 10915 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

Do you have a slow PC? Try a Free scan
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Inoue, Hiroshi 2014-06-17 09:07:22 Re: Why separate pgenlist DLL?
Previous Message Adrian Klaver 2014-06-17 01:53:19 Re: Doubt about ODBC Driver