freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
[freetds] patch: corrects the reading of large integer values when represented as double
- From: "Jose Luu" <jluu AT applia.fr>
- To: <freetds AT lists.ibiblio.org>
- Subject: [freetds] patch: corrects the reading of large integer values when represented as double
- Date: Wed, 19 May 2004 07:52:35 +0200
Hi,
An integer column datatype can be sent (and may be stored in the
database) as a double precision float.
In my case, 16 digit integers were transmitted this way and I was losing
the last digit (became always 0).
This is somehow a borderline case since only 90% of the 16 digit
integers can be represented using a double float. However, it would make
the library more robust to allow for such cases.
Also note that the Sybase openclient library is converting to 16 places.
In the patch below I have allowed for float8 conversion to 16 places.
This has been tested with freetds 0.62.1 by should work on the more
recent versions as the file convert.c has not changed.
--- src/tds/convert.c.orig Wed Jan 7 17:01:50 2004
+++ src/tds/convert.c Tue May 18 14:22:08 2004
@@ -1477,7 +1477,7 @@
memcpy(&the_value, src, 8);
switch (desttype) {
case CASE_ALL_CHAR:
- sprintf(tmp_str, "%.15g", the_value);
+ sprintf(tmp_str, "%.16g", the_value);
return string_to_result(tmp_str, cr);
break;
@@ -1535,7 +1535,7 @@
break;
case SYBNUMERIC:
case SYBDECIMAL:
- sprintf(tmp_str, "%.15g", the_value);
+ sprintf(tmp_str, "%.16g", the_value);
return stringz_to_numeric(tmp_str, cr);
break;
/* not allowed */
-
[freetds] patch: corrects the reading of large integer values when represented as double,
Jose Luu, 05/19/2004
- Re: [freetds] patch: corrects the reading of large integer values when represented as double, James K. Lowden, 05/19/2004
Archive powered by MHonArc 2.6.24.