[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug c/14384] Invalid use of extra precision floating-point with -O0 opt

From: anz at obs-nice dot fr
Subject: [Bug c/14384] Invalid use of extra precision floating-point with -O0 optimization
Date: 10 Mar 2004 16:30:15 -0000

------- Additional Comments From anz at obs-nice dot fr  2004-03-10 16:30 
(In reply to comment #13)
> no you are missing the point that f1+f2 is not done in double precission but
only done in single.
>    d1 = ((double)f1)+offset;
> Will give you the addition done in double precission.

NO, if the addition was done in single, 12345.123047 would be printed (twice)
(check with -mfpmath=sse -msse).
The fact that 12345.123456 is printed twice proves that BOTH additions are done
in double precision, because otherwise 12345.123456 would have been rounded to
12345.123047 because float has not enough accuracy to hold 12345.123456 exactly.
And if you use the line you wrote
>    d1 = ((double)f1)+offset;
you will see that it changes nothing because gcc computes with (double) extra
precision anyway.
And if it is OK to compute with extra precision in the first expression
   d1 = f1+offset;
it is not in the second
   d2 = addf(f1);
because there addf() has the return type float (and I even added an explicit
cast to to float), so the result *HAS* to be rounded to single precision and
produce 12345.123047 as result.

           What    |Removed                     |Added
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]