This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Floating point trouble wit x86's extended precision


Hi Volker,
> I wanted to construct a very extreme case where rounding leads to
> unexpected behaviour and came up with the following example:
>
> ============================================
> int main()
> {
>   double x = sqrt(2.0);
>   volatile double y = x;
>   if (x!=y) printf("Uh oh!\n");
>   return 0;
> }
> ============================================
>
> Compiling this with GCC 3.3.1 and using -O2 I get the output:
> "Uh oh!"

It should probably be pointed out that this may be a poor example
for GCC's WWW pages, as this particular test case is fixed in 3.4!
Mainline CVS evaluates sqrt(2.0) at compile-time and correctly
rounds it to double precision.

Perhaps, using sin(0.5) instead, will have a longer life-time...

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]