[erlang-questions] Bug? Pretty-printing floating point values
Wed Nov 21 17:59:19 CET 2007
"Christian S" <chsu79@REDACTED> wrote:
>Doesn't look like the number of significant digits when read are stored.
Undoubtedly true, but not necessarily relevant.
>I wouldn't call it a bug. It is how floating point numbers work.
>They're very exact with fractions that are a sum of limited numbers of
>negative powers of two though.
A reasonable question could be why float_to_list/1 generates 20 digits
when a 64-bit float (a.k.a. C double), which is what is used internally,
only can hold 15-16 worth of them - I don't know off-hand what a 128-bit
float would have, but presumably significantly more than 20, so it's not
that either. I guess way back in the dark ages, someone thought that 20
was a nice and even number (I hope it wasn't me:-). The 6.30000 form is
of course just the ~p/~w formatting.
Eshell V5.5.5 (abort with ^G)
More information about the erlang-questions