Re: float output precision questions

From: "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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 17:41:58
Message-ID: 3DC16B66.9020303@ualg.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> 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).

Yeahh! If there's a proof its safe to implement.
I also Googled a bit and found another paper saying that 17 is the
minimum number of significant digits guaranteed to distinguish among
IEEE double-precision floating point numbers:

"Robert G. Burger and R. Kent Dybvig. Printing floating-point numbers
quickly and accurately. In Proceedings of the ACM SIGPLAN '96 Conference
on Programming Language Design and Implementation, pages 108--116"
http://citeseer.nj.nec.com/28233.html

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

Off course. This is also good in terms of dump storage for big float8
databases. Its one byte less for every float8.

>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go 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
Portugal
Tel./Fax: (+351) 289 800950 / 289 819403
http://w3.ualg.pt/~pfrazao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2002-10-31 17:56:24 Re: 7.2.3 vacuum bug
Previous Message Bruno Wolff III 2002-10-31 17:15:16 Re: setuid for defaults, constraints and triggers (Was: What user to [sic] defaults execute as?)