Closed
Bug 261947
Opened 20 years ago
Closed 20 years ago
Floating point arithmetics can produce wrong results
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: escaillas, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
A simple operation like :
2.00000000000001 - 1
produces
1.0000000000000102
If the 15th digit of a float is not relevant, the comparison operator should not
take it into account as in :
1 == (1 / 54 + 1) * 54 - 54
wich resolves to :
1 == 1.000000000000007
Reproducible: Always
Steps to Reproduce:
1. document.write( 1 == (1 / 54 + 1) * 54 - 54 )
2.
3.
Actual Results:
false
Expected Results:
true
CPU is AMD Athlon 1.2 Ghz
printf("%99.99f\n", (1.0/54.0 + 1.0) * 54.0 - 54.0);
1.000000000000007105427357601001858711242675781250000000000000000000000000000000000000000000000000000
Your issue is with IEEE754 rules, not Mozilla.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Updated•20 years ago
|
Whiteboard: DUPEME
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
*** This bug has been marked as a duplicate of 20140 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
You need to log in
before you can comment on or make changes to this bug.
Description
•