This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Floating point in gcc
- To: <gcc-bugs at gcc dot gnu dot org>, <bug-gcc at gnu dot org>
- Subject: Floating point in gcc
- From: "Alexei A. Petrenko" <cap at sparc dot spb dot su>
- Date: Wed, 5 Jul 2000 14:39:49 +0400
Hi.
I'm using gcc on Linux for x86 (I've tried different Linuxes and
compiler versions with the same results) and have strange error. If we
compile this source:
#include <stdio.h>
int main(int argc, char *argv[]) {
double d1 = 1;
double d2 = (double)((1L<<12) + 1)/(1L<<12)/(1LL<<53);
double d3 = 1 + (double)((1L<<12) + 1)/(1L<<12)/(1LL<<53);
d1 += d2;
printf("%.70lf\n", d1);
printf("%.70lf\n", d3);
return 0;
}
We will see that first (d1) value will be 1.0 but d3 is little bit more
than 1.0. And the d3 value is correct.
If you will try this example on sparc-S2 (with SPARCompiler) or on Win32
with MSVC both results will be the same and correct.
Is this gcc bug? Or I can tell some option and everything will be ok ;)
SY, Alexei