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: dewar at gnat dot com, geoffk at geoffk dot org, kaih at khms dot westfalen dot de
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 12 Jul 2002 19:26:06 -0400 (EDT)
- Subject: Re: How to determine that 2.0 == (float) 2 in a front-end.
And the point is that (X**2)**2 may be less accurate than x*x*x*x so that
means you cannot freely replace the latter by the former.
Obviously no one is claiming that (x**2)**2 always is less accurate than
x*x*x*x.
As I mentioned before, in Ada 83, x**4 was defined as having the same model
interval as x*x*x*x which means you can only replace it by something else
(e.g. x**2**2) if you can prove that it never has a larger model interval
(which you can't as we see).
This was not really intended. Consequently in Ada 95 there is a special rule
that x**n is x*x*x ... x*x*x with any possible assocation being allowed, so
for example, you can evaluate
x*x*x*x
as
(x*x)*(x*x)
which is of course the same
as
x**2**2