Skip site navigation (1) Skip section navigation (2)

Re: float output precision questions

From: "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt>
To: "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>,Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>,Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: float output precision questions
Date: 2002-10-31 13:47:35
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Just one more note,

Maybe it makes sense that in the proposal below the parameter 
EXTRA_DIGITS could be SIGNIFICANT_DIGITS with a default value of 15 and 
maximum 18.
Its more 'documentable' and maybe easy to understand in general.

Pedro M. Ferreira wrote:

> Yes. I think there are several options.
> I checked the sprintf(ascii, "%A", num) output format and all the 
> numbers that would fail because of DBL_DIG=15 are ok. After insertion on 
> a table and conversion to double after a query, comparison a==b holds.
> AFAICT "%A" is system independent.
> I would (if I may) propose the following:
> Have two parameters, say DOUBLE_OUTPUT and EXTRA_DIGITS. DOUBLE_OUTPUT 
> would select from decimal output or normalized output. EXTRA_DIGITS 
> would add the required extra digits, from 0 (default) to 3,  when output 
> is decimal.
> in the range [0:3]. 0 as defualt.
> 'DECIMAL': sprintf(ascii, "%.*g", DBL_DIG+EXTRA_DIGITS, num); (default)
> 'NORMALIZED': sprintf(ascii, "%A", num);
> The same could be done for floats (float4).
> This way PG does not assume anything (DOUBLE_OUTPUT as 'NORMALIZED'), it 
> does not hardwire 'inappropriate' assumptions about the number of 
> significant digits in a double (default EXTRA_DIGITS=0), and it gives 
> flexibility (EXTRA_DIGITS!=0) if needed.
> I think this is functional and reasonable.
> Regards,
> Pedro M. Ferreira
>>             regards, tom lane
>> ---------------------------(end of broadcast)---------------------------
>> TIP 2: you can get off all lists at once with the unregister command
>>     (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

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

In response to

pgsql-hackers by date

Next:From: Zeugswetter Andreas SB SDDate: 2002-10-31 14:28:48
Subject: Re: float output precision questions
Previous:From: Pedro M. FerreiraDate: 2002-10-31 12:31:47
Subject: Re: float output precision questions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group