Skip to Content.
Sympa Menu

freetds - Re: [freetds] tds_money_to_string conversion oddity

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • 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: Sun, 7 Dec 2003 07:59:46 -0600

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




Archive powered by MHonArc 2.6.24.

Top of Page