Re: float output precision questions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: float output precision questions
Date
Msg-id 7322.1036080081@sss.pgh.pa.us
Whole thread Raw
In response to Re: float output precision questions  ("Pedro M. Ferreira" <pfrazao@ualg.pt>)
List pgsql-hackers
"Pedro M. Ferreira" <pfrazao@ualg.pt> writes:
> Its like I said before, the guys from matlab (in x86 IEEE float) go to 
> DBL_BIG+3 to have 'maximum precision'.

Apparently they have not read the canonical papers in the field.
[ googles for a moment... ]  See
How to read floating point numbers accuratelyWilliam D. Clinger How to print floating-point numbers accuratelyGuy L.
Steele,Jr., Jon L. White 
 

both published at the 1990 ACM Conference on Programming Language Design
and Implementation and subsequently reprinted in ACM SIGPLAN Notices
Volume 25, Issue 6 (June 1990).

I was misremembering these papers to claim DBL_DIG+1 is enough, but
actually they prove that DBL_DIG+2 is necessary and sufficient (and
give code to do it correctly, too).

Printing DBL_DIG+3 is just producing an extra garbage digit; it won't
help matters.  Any reasonably well-written C library is going to be
able to reproduce a double value with DBL_DIG+2 digits of I/O; and if
it's not well-written, I would have no confidence in its ability to do
so with DBL_DIG+3 digits...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: float output precision questions
Next
From: Rod Taylor
Date:
Subject: Re: setuid for defaults, constraints and triggers (Was: