[freetds] tds_money_to_string conversion oddity

Craig A. Berry craigberry at mac.com
Sun Dec 7 07:59:46 EST 2003


At 2:01 PM +0100 12/7/03, Frediano Ziglio wrote:
>Il dom, 2003-12-07 alle 07:17, James K. Lowden ha scritto:

> >	sprintf(s, "%.02f", atof(s));
>>
> > should do the trick, I think. 

Yes, I think so, thanks.

>I rewrite some code yesterday so this code compile only on platform that
>do not support a 64bit int (mainly for performance reasons)...

Actually from browsing CVS it looks like the test you are doing is:

#if SIZEOF_LONG < 8

which means that sizeof(long int) < 8, but I think what you really
want is sizeof(long long int) or perhaps sizeof(__int64)  since a
long int is sometimes (usually?) still 32 bits even on 64-bit
platforms.  I also see no advantage to using the config macro rather
than the sizeof operator directly.

> Note however that conversion from money to double can lose
>precision and should be avoided...

But we are still testing for it, right?

-- 
________________________________________
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