Closed Bug 251585 Opened 20 years ago Closed 20 years ago

Calculating Error

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 5856

People

(Reporter: ca_boe, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de-AT; rv:1.6) Gecko/20040113
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-AT; rv:1.6) Gecko/20040113

A bug that occured recently. My newest example:

alert(2.3*1.15)

this should alert "2.645", but the massage is "2.6449999999999996". This error
occurs also in IE, and if I remember correctly also under Linux.

Reproducible: Always
Steps to Reproduce:
1. alert(2.3*1.15)

Actual Results:  
2.6449999999999996

Expected Results:  
2.645
See bug 5856 comment 1.

*** This bug has been marked as a duplicate of 5856 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
But note that you can use toFixed(2), e.g., to get good "dollars and cents"
results: click on javascript:alert((2.3*1.15).toFixed(2)) to see the result.

/be
You need to log in before you can comment on or make changes to this bug.