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 15:27:10
Message-ID: 3DC691CE.6070408@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:
>
>>int extra_float4_digits, default 0, min -4, max 2
>>int extra_float8_digits, defualt 0, min -13, max 2
>
>
> I think a single setting extra_float_digits would be sufficient.

Ok. Assuming,

int extra_float_digits, default 0, min -13, max 2

If extra_float_digits==-13 and we are outputing a float4 this results in
a negative value for FLT_DIG+extra_float_digits. I dont know if
sprintf's behaviour is the same across different libraries for this
situation.

Should I include the following to handle this case ?

if(extra_float_digits<-4)
sprintf(ascii, "%.*g", FLT_DIG-4, num);
else
sprintf(ascii, "%.*g", FLT_DIG+extra_float_digits, num);

>
>
>>Also, if we concluded that there is a need of 2 more digits, should'nt
>>this be the default ?
>
>
> No. pg_dump would want to bump it up on-the-fly.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>

--
----------------------------------------------------------------------
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-11-04 15:33:09 Re: Float output formatting options
Previous Message Tom Lane 2002-11-04 14:46:43 Re: Float output formatting options