freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] tds_money_to_string conversion oddity
- From: "Craig A. Berry" <craigberry AT mac.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] tds_money_to_string conversion oddity
- Date: Sat, 06 Dec 2003 18:04:17 -0600
Craig A. Berry wrote:
/* round to two decimal places */
if (s) {
sprintf(s, "0.%02f", atof(s));
}
But before this code in the example where I encounter the problem, s is "1.0000", so that after this code, the value of s is "0.1.000000".
I think I placed too much faith in there being a reason for the exact
layout of the format string. The attached patch solves the problem by
putting the "0." where it belongs (after the percent sign).
--- src/tds/numeric.c;-0 Fri Dec 5 14:47:56 2003
+++ src/tds/numeric.c Sat Dec 6 17:47:44 2003
@@ -96,7 +96,7 @@
*s++ = '-';
i = -i;
}
- sprintf(s, "0.%02d", i);
+ sprintf(s, "%0.02d", i);
}
return s;
#else
@@ -155,7 +155,7 @@
/* round to two decimal places */
if (s) {
- sprintf(s, "0.%02f", atof(s));
+ sprintf(s, "%0.02f", atof(s));
}
return s;
-
[freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/06/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/06/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
James K. Lowden, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Frediano Ziglio, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Frediano Ziglio, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/07/2003
- Re: [freetds] tds_money_to_string conversion oddity, Frediano Ziglio, 12/08/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
James K. Lowden, 12/07/2003
- Re: [freetds] tds_money_to_string conversion oddity, Frediano Ziglio, 12/08/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Frediano Ziglio, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Frediano Ziglio, 12/07/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
James K. Lowden, 12/07/2003
- <Possible follow-up(s)>
-
RE: [freetds] tds_money_to_string conversion oddity,
Lowden, James K, 12/08/2003
- RE: [freetds] tds_money_to_string conversion oddity, Chris Eleveld, 12/08/2003
-
Re: [freetds] tds_money_to_string conversion oddity,
Craig A. Berry, 12/06/2003
Archive powered by MHonArc 2.6.24.