[freetds] tds_money_to_string conversion oddity

Craig A. Berry craigberry at mac.com
Sat Dec 6 17:40:55 EST 2003


I'm seeing an odd thing in trying to track down a failure running 
src/tds/unittests/convert.c.  The top-level symptom is

failed (-3) to convert 60 (money, 8 bytes) : 108 (numeric).

Stepping through in the debugger, I can see that the money argument 
to tds_money_to_string is 2061629744.  At the very end of the routine 
there is the following rounding code, which seems to assume s 
contains a string representation of a fractional number:

        /* 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". 
That's of course what you would expect sprintf to do given those 
inputs, but it's not a valid thing to turn around and pass to 
string_to_numeric.  Any thoughts on how to debug this further?

My environment is, Compaq C V6.5-001 on OpenVMS Alpha V7.3-1, 
building the 20031206 snapshot.

-- 
________________________________________
Craig A. Berry
mailto:craigberry at mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser


More information about the FreeTDS mailing list