Bug 629 - floating point comparison
Summary: floating point comparison
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-10-11 22:46 UTC by deshpand
Modified: 2003-07-01 18:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test.cpp (319 bytes, application/octet-stream)
2003-05-21 15:16 UTC, deshpand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description deshpand 2000-10-11 22:46:01 UTC
Floating point comparison fails when done through
a function call from a class.

Release:
gcc version 2.95.2 19991024 (release)(Using g++)

Environment:
Bug is only on Linux for x86

How-To-Repeat:
The code contains the bug and its workaround
Comment 1 deshpand 2000-10-11 22:46:01 UTC
Fix:
The workaround is in the file submitted
Comment 2 Neil Booth 2001-02-04 06:31:49 UTC
State-Changed-From-To: open->closed
State-Changed-Why: This is not a bug, but a consequence of the CPU's FPU and
    in-memory representation of f.p. numbers being different.
    
    You cannot reliably use == to compare floating point numbers;
    you need to use fabs (a-b) < epsilon, or similar.
Comment 3 Neil Booth 2001-02-04 14:31:49 UTC
From: neil@gcc.gnu.org
To: deshpand@cs.umn.edu, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/629
Date: 4 Feb 2001 14:31:49 -0000

 Synopsis: floating point comparison
 
 State-Changed-From-To: open->closed
 State-Changed-By: neil
 State-Changed-When: Sun Feb  4 06:31:49 2001
 State-Changed-Why:
     This is not a bug, but a consequence of the CPU's FPU and
     in-memory representation of f.p. numbers being different.
     
     You cannot reliably use == to compare floating point numbers;
     you need to use fabs (a-b) < epsilon, or similar.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=629&database=gcc
Comment 4 Andrew Pinski 2003-07-01 18:38:15 UTC
Reopening bug to mark bug as a dup of bug 323 so ...
Comment 5 Andrew Pinski 2003-07-01 18:39:13 UTC
that the number of dup goes up on that bug.

*** This bug has been marked as a duplicate of 323 ***