Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wwk16-0003X9-Lz for pgsql-odbc@arkaria.postgresql.org; Tue, 17 Jun 2014 03:25:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wwk15-0001lG-Aq for pgsql-odbc@arkaria.postgresql.org; Tue, 17 Jun 2014 03:24:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wwk14-0001l9-D8 for pgsql-odbc@postgresql.org; Tue, 17 Jun 2014 03:24:58 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by makus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wwk10-0006VN-0o for pgsql-odbc@postgresql.org; Tue, 17 Jun 2014 03:24:56 +0000 Received: (qmail 3586 invoked by uid 512); 17 Jun 2014 03:24:52 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.126.1.62) by sd2.tpf-fw-c.co.jp with SMTP; 17 Jun 2014 03:24:52 -0000 Message-ID: <539FB503.3090103@tpf.co.jp> Date: Tue, 17 Jun 2014 12:24:51 +0900 From: "Inoue, Hiroshi" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: John Smith CC: "pgsql-odbc@postgresql.org" Subject: Re: Precision problems with storage of float/double References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org (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 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc