Closed Bug 699645 Opened 13 years ago Closed 13 years ago

[Javascript] Wrong comparision (0.55*100 == 55) always return false

Categories

(Firefox :: General, defect)

10 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 5856

People

(Reporter: nghiad85, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1

Steps to reproduce:

In my code there is one compassion like
var x = 0.55
if (x*100 == 55) {
// do something
} 


Actual results:

There is no way to make the condition to true. 


Expected results:

0.55*100 == 55 should return true
Learn about floating point number calculation.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Ok, my question is 
Why 0.33*100 returns 33 but 0.55*100 returns 55.00000000000001.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.