JavaScript floating-point precision error

RESOLVED DUPLICATE of bug 5856

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 5856
13 years ago
13 years ago

People

(Reporter: Jeremiah Blatz, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

13 years ago
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
Last Resolved: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.