This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] Rework of floating point number reading
On Tue, Dec 30, 2008 at 06:31:08PM +0100, Daniel Kraft wrote:
> For anyone interested, I looked at glibc-2.4 (the one on my system) 's
> implementation, which is in stdlib/strtod_l.c and around 1600 lines of
> code; I would not want to include this one in gfortran, to be honest.
>
> The basic idea is to to the same as my patch does, but use a gmp natural
> number for the *10+digit thing. For the division, it uses a table of
> powers of ten instead of pow and copied code from GMP because it states
> that not a full multiprecision division is needed but instead only a few
> digits. So here's another suggestion: Do the calculation ourselves but
> use GMP for it? I think we could do a simple code, not that optimized
> and special-case-handling as the one in glibc, but (hopefully) with the
> same precision. It seems (?) that strtod uses GMP anyway, so can we do
> that, too, in libgfortran? Or are there systems libgfortran is supposed
> to work on even without GMP (there we could simply use floating-point
> numbers and allow the loss of precision)? I hesitated to do my
> calculation with large integers in the first place because I feared slow
> code; but if glibc does it, it can't be too bad, I guess.
>
Daniel,
You may want to check out how David Gay handles the conversion.
See g_fmt.c at http://www.netlib.org/fp/index.html
--
Steve