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: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] tds_money_to_string conversion oddity
  • Date: Sun, 07 Dec 2003 14:18:26 -0000

Il dom, 2003-12-07 alle 14:59, Craig A. Berry ha scritto:
> 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.
>

No, usually on 64bit long is 64bit... The only 64bit platform that do
not have a native C int 64 is windows... you know, compatibility
problems...
The problem here is: does printf support %lld ?? To avoid check I split
number in two long and used two %ld.

> > Note however that conversion from money to double can lose
> >precision and should be avoided...
>
> But we are still testing for it, right?

IMHO sprintf should not be used and code for old platforms should be
rewritten... however I don't really know if other money code in
convert.c work for such platform... Do anyone know a test platform I can
use or just can do some tests for me?

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page