[Patch, Fortran] Rework of floating point number reading

Daniel Kraft d@domob.eu
Tue Dec 30 10:37:00 GMT 2008


Hi Geert,

thanks for your comments!

Geert Bosch wrote:
> Realize that strtod and similar functions nowadays correctly
> round input values. This means you'll guaranteed to get the floating
> point number closest to the input number. If you do your own
> computation using a pow() function, you won't get last-bit
> accuracy.

This is what I wondered about most, too (and why I wanted to get some 
results from other platforms than mine as well).  I agree that strtod is 
of course the "best" solution for parsing numbers in this respect, as it 
is probably much better optimized in general and on the target system as 
anything we can come up here easily.

On the other hand, I'm not particularly sure, if time really does not 
matter here; while I've never written real, large Fortran programs 
myself, I could imagine thad *reading* large data sets can actually be a 
significant part of a program's runtime.

Possible solutions I see:

1.) Check other compilers and decide the rounding error is not that much 
of a problem.

2.) Allow the user to choose, maybe something like -ffast-math for IO 
(don't know what to think about this).

3.) Keep using strtod; I'm quite sure we can speed up the existing code 
still significantly by optimizing how the string passed to strtod is 
constructed.

Yours,
Daniel

-- 
Done:  Arc-Bar-Cav-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri-Ran



More information about the Fortran mailing list