This is the mail archive of the
mailing list for the GCC project.
Re: Floating poing 'non-bug'? Or is this a bug?
- From: Jim Wilson <wilson at specifixinc dot com>
- To: Yuval Kfir <yuvalk at mainsoft dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 06 Jul 2004 18:47:04 -0700
- Subject: Re: Floating poing 'non-bug'? Or is this a bug?
- References: <email@example.com>
Yuval Kfir wrote:
The short program below gives '5*1.2=5' when compiled
without -DDOUBLE_INTER, but '5*1.2=6' with the double-precision intermediate
This is yet another instance of the "excess precision" problem. This is
partly a problem with the x86 FPU design which provides only
double-extended precision operations. And this is partly a problem with
the design of the x86 gcc backend, which lies, and claims that we have
float and double precision operations.
You should get the same result in both cases, but you get a different
result for one because an intermediate value is written to the stack
(fstpl) which rounds it to a double, and then loaded back (fldl). In
the other case, the intermediate value is not written to the stack, and
remains a double-extended value with excess precision.
This will probably only be fixed when the entire world switches to AMD
AMD64 and/or Intel EM64T machines, and stops using x87 FP register-stack
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com