Re: Float output formatting options

From: "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Float output formatting options
Date: 2002-11-04 16:51:10
Message-ID: 3DC6A57E.8090207@ualg.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Pedro M. Ferreira" <pfrazao(at)ualg(dot)pt> writes:
>>
>>If extra_float_digits==-13 and we are outputing a float4 this results in
>>a negative value for FLT_DIG+extra_float_digits.
>
> You would want to clamp the values passed to %g to not less than 1.
> I'd favor code like
> int ndig = FLT_DIG + extra_float_digits;
> if (ndig < 1)
> ndig = 1;
> sprintf(ascii, "%.*g", ndig, num);
>
> Probably best to do it this way with float8 too; otherwise we're
> essentially wiring in the assumption that we know what DBL_DIG is.
> Which is exactly what we're trying to avoid doing.

Good.
Corrected this, compiled and tested it. Works fine.

I am attaching the diff's made with diff -u. Sources were from Debian
source package Version 7.2.1-2woody2.

Best regards,
Pedro

>
> regards, tom lane
>
>

--
----------------------------------------------------------------------
Pedro Miguel Frazao Fernandes Ferreira
Universidade do Algarve
Faculdade de Ciencias e Tecnologia
Campus de Gambelas
8000-117 Faro
Portugal
Tel./Fax: (+351) 289 800950 / 289 819403
http://w3.ualg.pt/~pfrazao

Attachment Content-Type Size
float.c.diff text/plain 1.7 KB
guc.c.diff text/plain 872 bytes
tab-complete.c.diff text/plain 309 bytes
postgresql.conf.sample.diff text/plain 417 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-11-04 16:56:41 Re: Float output formatting options
Previous Message Tom Lane 2002-11-04 15:33:09 Re: Float output formatting options