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: Mon, 08 Dec 2003 22:07:22 -0000

Il lun, 2003-12-08 alle 19:47, Craig Berry ha scritto:
> On Monday, December 08, 2003, at 09:17AM, Lowden, James K
> <LowdenJK AT bernstein.com> wrote:
>
> >> From: Craig A. Berry [mailto:craigberry AT mac.com]
> >> Sent: December 7, 2003 9:00 AM
> >>
> >> 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.
> >
> >On Alpha Tru64, a long is 64 bits. What 64-bit system do you use that has
> >a
> >32-bit long?
>
> VMS on Alpha and Itanium. Freddy indicated Windows also does this, and
> someone else has now pointed out AIX does the same thing. And there's no
> particular reason that a compiler on a 32-bit architecture might not
> support 64-bit integers one way or another. It's more complicated than I
> thought, but my original point (which I didn't express very clearly) still
> holds, namely that if what we want to test for is whether 64-bit integers
> are available and supported, sizeof(long) is a poor indicator of that. The
> Configure script for Perl provides an example of how to figure out whether
> 64-bit integers are available and what to call them if they are: do a grep
> on "quadtype". Maybe it's not important enough to go to that trouble, but
> I get the feeling from Freddy's comments that it's much better to use them
> if you have them.

I'm getting a bit confused... FreeTDS detect the 64 bit type
(TDS_INT8/TDS_UINT8) however the problem is printf formatting. We do not
define a 64 bit formatting... With #if SIZEOF_LONG < 8 line I detect if
%ld accept a 64 bit int (or in other words if long is 64 bit). %lld
isn't so portable and so I used %ld. Perhaps a test for printf
formatting and some define can help... For example gcc accept long long
however system library supports %lld?? Windows accepts %i64. I think
some platforms do not accept 64 bit int... So there is not a portable
way to transform a 64 bit int to a string...

#if SIZEOF_LONG < 8 do not test for 64 bit support. Test for 64 bit
support in numeric.c is #ifdef HAVE_INT64 above.

Problems still persists for system that do not supports 64 bit (that is
there are no long long/int64 or whatever extension and long is only 32
bit). Here we use a sprintf that can cause lose of precision. However
such systems have others problem in convert.c... Should we fix these
problems too or should we require 64 bit support ?? The only system I
know is the old good DOS...

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page