Weird floating point display?
Kent Boortz
kent@REDACTED
Thu Aug 29 01:34:47 CEST 2002
James Hague <jamesh@REDACTED> writes:
> >From the R8B-2 shell, under Windows:
>
> > 1.0
> 1.00000
> > 0.0
> 0.00000e+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,
kent
Ref:
Clinger, William D. How to read floating point numbers accurately.
In [ACM PLDI, 1990], pp. 92--101.
http://www.acm.org/pubs/citations/proceedings/pldi/93542/p92-clinger/
http://citeseer.nj.nec.com/clinger90how.html
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.
http://www.acm.org/pubs/citations/proceedings/pldi/93542/p112-steele/
More information about the erlang-questions
mailing list