This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Casting and Optimization Flags
- From: "Hillel (Sabba) Markowitz" <sabbahem at bcpl dot net>
- To: GCC Help <gcc-help at gcc dot gnu dot org>
- Cc: c dot law at elec dot gla dot ac dot uk
- Date: Wed, 11 Dec 2002 12:09:07 -0500
- Subject: RE: Casting and Optimization Flags
-------------------- Original Message ----------------------------------
From: Colin Law <c dot law at elec dot gla dot ac dot uk>
To: Rob Shearer <Rob dot Shearer at networkinference dot com>, eljay at
adobe dot com
Cc: gcc-help at gcc dot gnu dot org
Date: Wed, 11 Dec 2002 13:39:38 +0000
Subject: Re: Casting and Optimization Flags
References:
<3BE4D3F0FB726240966DEF40418472B502EC6F@NI-LON-SERVER1.ad.networkinference.com
>
casting floats to integers does not round; it truncates
Thanks for the replies. Why was this behaviour more (only!) obvious when I
used the compiler optimization flags? Had I not tried this, I would be quite
oblivious to the problem, which could have been very
difficult to track down futher down the line.
Thanks for the bit twiddling hack link Eljay, some of these will do exactly
what I'm looking for.
~Colin.
---------------------- End Original Message --------------------------------
On some platforms there is a difference in accuracy between the memory and the
register arithmetic for floating point numbers. When you ran without
optimization, the values were stored in memory along the way. Under
optimization, they happened to jus be kept in registers with enough of a
difference to trigger the error that you saw.
--
Said the fox to the fish, "Join me ashore".
The fish are the Jews, Torah is our water
Hillel (Sabba) Markowitz - sabbahem@bcpl.net