top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What comparison of two same float numbers result in false?

0 votes
447 views

Say
float i = 1.1;
float j = 1.1;

Many a time if (i == j) results in false. Why??

posted Aug 1, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

I think its not possible.

Please check your question. Maybe its
float i = 1.1;
double j = 1.1;

And when you compare these 2 , i.e (i == j), the result will be 0 or false.
It involves the concept of the IEEE 754 Standard for storing Floating-Point and Double.

If thats the case, we can have a discussion on that.

answer Aug 2, 2014 by Ankush Surelia
0 votes

In my machine it is working fine.
Can you please share the machine and compiler details ?

answer Aug 1, 2014 by Ganesh
...