Re: float output precision questions
От | Tom Lane |
---|---|
Тема | Re: float output precision questions |
Дата | |
Msg-id | 7322.1036080081@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: float output precision questions ("Pedro M. Ferreira" <pfrazao@ualg.pt>) |
Список | 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 по дате отправления: