Closed Bug 297361 Opened 17 years ago Closed 17 years ago

JavaScript floating-point precision error

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 5856

People

(Reporter: buzilla, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Floating-point arithmetic has precision errors. Try 71+20+1.8+3.6, it gives 96.39999999 instead of 
96.4. This has been verified on Windows and MacOS.

Reproducible: Sometimes

Steps to Reproduce:
1. put in the URL box: javascript:alert(eval("71+20+1.8+3.6"));
2: hit enter
3: enjoy a fine beverage
Actual Results:  
Got an alert with 96.39999999

Expected Results:  
Gicen an alert with 96.4

In all fairness, IE and Safari also suffer from this.

*** This bug has been marked as a duplicate of 5856 ***
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.