Weird floating point display?
Thu Aug 29 01:34:47 CEST 2002
James Hague <> writes:
> >From the R8B-2 shell, under Windows:
> > 1.0
> > 0.0
> Why the "e+0" in the second case?
There is nothing wrong with "0.00000e+0" ;-)
We use the normal posix routines on the operating system to do the
conversion so different libc libraries will give different results.
The conversion from the binary format to text is done in C using
sprintf(buf, "%.20e", fp);
You could never expect that converting floating point to and from the
binary representation to text will give exactly what you may expect
but there is room for improvements,
Clinger, William D. How to read floating point numbers accurately.
In [ACM PLDI, 1990], pp. 92--101.
G. L. Steele Jr. and J. L. White. How to print floating-point
numbers accurately. In Proceedings of the ACM SIGPLAN '90 Conference
on Programming Language Design and Implementation, pages 112--126,
White Plains, New York, June 1990.
More information about the erlang-questions