Closed
Bug 408202
Opened 17 years ago
Closed 17 years ago
Javascript modulo operator returns incorrect result when using floating point numbers
Categories
(Firefox :: General, defect)
Tracking
()
People
(Reporter: rob, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
This statement, (23.98*3600) % 23.98, yields the answer 23.979999999998466, which is obviously illogical. (24*3600) % 24 yields 0, which is correct. (59.97*3600) % 59.97 yields 4.092726157978177e-12, which is way off the mark.
This happens in html pages, but can also be seen in the error console.
Reproducible: Always
Steps to Reproduce:
1. Open error console
2. Type in (23.98*3600) % 23.98 in the evaluate field
3. Press Evaluate
Actual Results:
Messages window displays 23.979999999998466
Expected Results:
Message window should display 0
Comment 1•17 years ago
|
||
This is just the general issue with the presumed accuracy of floating point values.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•