| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Float output formatting options |
| Date: | 2002-11-04 15:33:09 |
| Message-ID: | 4535.1036423989@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
"Pedro M. Ferreira" <pfrazao(at)ualg(dot)pt> writes:
> Tom Lane wrote:
>> 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.
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.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pedro M. Ferreira | 2002-11-04 16:51:10 | Re: Float output formatting options |
| Previous Message | Pedro M. Ferreira | 2002-11-04 15:27:10 | Re: Float output formatting options |