This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] patch for output of real values on windows systems
Steve Kargl <sgk@troutmask.apl.washington.edu> writes:
> > newlib (http://sourceware.org/newlib/) includes an implementation of
> > dtoa, originally by David Gay, which is said to correctly represent
> > floating point values, based on Steele and White's algorithm. It's in
> > newlib/libc/stdlib/dtoa.c. The original version is probably available
> > from netlib. There is similar code in other free C libraries.
> > There's no need to roll your own code to convert floating point values
> > to printable form.
>
> Is newlib GPL+exception compatible? Does David Gay
> have a copyright assigment on file with FSF?
The dtoa.c file is under the BSD license. David Gay does not have a
copyright assignment on file. We've incorporated BSD license code
into libstdc++ releases in the past. I don't know if it would be OK
to put this file into a gcc release. If we want to seriously pursue
this, that is a question for the FSF.
Incidentally, the newlib code is here:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/stdlib/dtoa.c?cvsroot=src
The original author's updated version of the dtoa.c code is here:
http://netlib.org/fp/dtoa.c
The NetBSD version of the same code is here:
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdlib/strtod.c
I don't know which version would be more useful.
There is of course similar code in glibc, in stdio-common/printf-fp.c,
under the LGPL.
Or, if necessary, either algorithm could be reimplemented, or the
algorithm from the paper could be reimplemented.
I suppose my meta point is that printing floating point numbers is a
hard problem, but it is a solved problem.
Ian