This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to determine that 2.0 == (float) 2 in a front-end.
- From: dewar at gnat dot com (Robert Dewar)
- To: gcc at gcc dot gnu dot org, toon at moene dot indiv dot nluug dot nl
- Date: Tue, 25 Jun 2002 18:24:26 -0400 (EDT)
- Subject: Re: How to determine that 2.0 == (float) 2 in a front-end.
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).