Skip to Content.
Sympa Menu

freetds - RE: [freetds] patch: corrects the reading of large integer valueswhen represented as double

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] patch: corrects the reading of large integer valueswhen represented as double
  • Date: Wed, 19 May 2004 16:04:20 +0200

>
> On Wed, 19 May 2004, "Jose Luu" <jluu AT applia.fr> wrote:
> > In my case, 16 digit integers were transmitted this way and I was
> > losing the last digit (became always 0).
> >
> > This is somehow a borderline case since only 90% of the 16 digit
> > integers can be represented using a double float. However,
> it would make
> > the library more robust to allow for such cases.
> > Also note that the Sybase openclient library is converting
> to 16 places.
> >
> > In the patch below I have allowed for float8 conversion to
> 16 places.
>
> Thanks, Jose. I applied your patch. I'm not completely
> convinced it's
> right, but it is (at least) harmless and seems to be compatible with
> Sybase's implementation.
>
> IIRC, double precision is good only for 15 positions. Frediano once
> showed me how to examine the bit pattern, to know how
> precisely a number
> can be so represented. I'd like to be convinced that your
> 16th position
> is significant.
>

Mmm...

>From printf docs:

"precision specifies the maximum number of significant digits printed"

double have 53 bits of precision (52 + 1 implicit), so it's

log 2^53 = 15,95...

So, yes, 16 seems better...

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page