How to determine that 2.0 == (float) 2 in a front-end.

Robert Dewar dewar@gnat.com
Tue Jun 25 18:04:00 GMT 2002


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. I would not have imagined that any Fortran
compiler would still make that elementary mistake. The only time you can
compute x**y this way is if you have a significantly longer precision for
the intermediate result (e.g. the 80-bit extnded form on x86 is just right
for accurately computing x**y using log/exp).



More information about the Gcc mailing list