This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Optimization.
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Manan <mchopra at wisc dot edu>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 02 Apr 2005 11:33:38 +0100
- Subject: Re: GCC Optimization.
- Organization: CodeSourcery
- References: <424DEE22.7030009@wisc.edu>
Manan wrote:
Below is the part of code in which i am seeing this behaviour. Red line
is the exact line which gives different results with and without
optimization.
What red line?
The value of x[i] at that point is 1.5(exact) value of box_xh is 2.1
and rnx is 0.6 so icelx should evaluate to 6. which it does if i dont
use optimization but when i switch optimization it gives icelx = 5.
which is not correct.
So can some please tell me what i am doing wrong in this code.
You are presuming that the computer represents decimal floating point
values exactly. Refer to
What Every Computer Scientist Should Know about Floating-Point Arithmetic by
David Goldberg, including Doug Priest's supplement (PDF format)
linked to from the gcc 'further readings' page.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk