This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Avoiding floating point problems on Pentium Xeon platform w/ GCC 3.2
- From: "Kleinbussink, Erik" <erik dot kleinbussink at lmco dot com>
- To: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 09 Jun 2003 00:10:21 -0400
- Subject: Avoiding floating point problems on Pentium Xeon platform w/ GCC 3.2
I am porting an engineering application which uses double precision
calculations from its original platform (Alpha-based Tru64 UNIX) to Intel
Xeon-based linux. I have run into problems with floating point handling.
Below is one of the situations I ran into.
int main()
{
double d1, d2;
int i1, i2;
d1 = 0.04;
i1 = 100;
i2 = 100;
d2 = i1 / d1;
i1 = d2;
i2 = i2 / d1;
printf("%d %d\n", i1, i2);
return 0;
}
On Alpha, the above application results in "2500 2500", but on Intel Xeon,
it results in "2500 2499".
I have been reading gcc documentation, and it sounds like this is a known
complaint with x86 series chips. I am interested in help on what the best
course of action is?
- Review / Rework all source code manually (Very painful)
- Neat compiler flags/tricks which make this problem not a
problem...
Erik