https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70175

            Bug ID: 70175
           Summary: Condition comparing two float numbers
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slaver75 at gmail dot com
  Target Milestone: ---

When I try compare  two numbers whitch are equal using condition "==" i get
false than true.

Host used to build is gcc 4.9.2 for Qt Creator 5.5 on windows xp 32-bit.

For this example:
int main()
{
    double a = 2121;
    double b = 15.9075;
    double w = (0.0075*a);
    cout << a << " " << b << " " << w << endl;
    if (b == w) cout << "true";
    else cout << "false";
}
program print false altrough in a line 6 function cout print that variable w is
equal 15.9075.

In other cases ewerything is fine and program print true, for example when a =
2000 and b = 15 then w = 15 and condition (b == w) is true.

Reply via email to