How to determine that 2.0 == (float) 2 in a front-end.
Toon Moene
toon@moene.indiv.nluug.nl
Wed Jun 26 14:58:00 GMT 2002
Robert Dewar wrote:
> I wrote:
>> Obviously, because X**Y, with Y real, is implemented by computing
>> EXP(Y*LOG(X)) one doesn't want to change 2.0 to 2 lightly (i.e.,
>> without the assurance of -funsafe-math_optimizations).
>
> Gosh I hope not! computing x**y that way is horribly inaccurate even with
> perfect log and exp functions.
No, that was a brain-fart - thanks for alerting me to it. g77 generates
a call to the `pow' function in the C library, thereby shifting the
blame.
I initially thought I had seen this in libf2c, but
gcc/libf2c/libF77/Version.c doesn't mention a switch from exp(y*log(x))
to pow(x,y) in its "ChangeLog", so it must have been there from 1980
onwards.
Sorry, I don't know where I got the idea from ...
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
More information about the Gcc
mailing list