------- Comment #4 from jakub at gcc dot gnu dot org  2010-09-16 17:13 -------
i?86 is a FLT_EVAL_METHOD 2 target, so for strict C compliance all floating
operations and constants are supposed to be evaluated in the precision
of long double.  The assignment of the constant to a double var or explicit
cast to double cause rounding to happen, so your testcase is evaluated as:
  int main()
      double z = 3.14159265358979323846L;
      puts((long double) z == 3.14159265358979323846L ? "==" : "!=");
      return 0;
and of course (double) 3.14159265358979323846L != 3.14159265358979323846L.
You can use -fexcess-precision=fast (the default unless -std=c99/-std=c89
is requested) for the old behavior, or you can add explicit cast,
z == (double) M_PI, or (as usually a good idea) avoid floating point
equality/non-equality comparisons, instead check whether difference is
smaller than some epsilon. 



Reply via email to