Closed
Bug 281659
Opened 20 years ago
Closed 20 years ago
Floating point error in javascript
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: system252001, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.7.5) Gecko/20041210 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.7.5) Gecko/20041210 Firefox/1.0
I think I may have found a floating point error in javascript. If you make a web
page like this.
<html>
<head>
<title>Fallo en Javascript</title>
</head>
<body>
<script>
<!--
var n;
n=35;
n*=0.01;
document.writeln("35*0.01 es "+n+"<br>");
n2=0.35;
document.writeln("0.35 es "+n2+"<br>");
-->
</script>
</body>
</html>
The result is:
35*0.01 es 0.35000000000000003
0.35 es 0.35
Can you explaint it?
Reproducible: Always
Steps to Reproduce:
1. User this script:
<html>
<head>
<title>Fallo en Javascript</title>
</head>
<body>
<script>
<!--
var n;
n=35;
n*=0.01;
document.writeln("35*0.01 es "+n+"<br>");
n2=0.35;
document.writeln("0.35 es "+n2+"<br>");
-->
</script>
</body>
</html>
2. See the result:
35*0.01 es 0.35000000000000003
0.35 es 0.35
3. Is it wrong?
Actual Results:
I suppose that is a floating point error.
My computer is a Pentium 4 (R) 2.40 GHz
Updated•20 years ago
|
Assignee: firefox → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → pschwartau
Version: unspecified → Other Branch
![]() |
||
Comment 3•20 years ago
|
||
For IEEE doubles, that is the right behavior.
*** This bug has been marked as a duplicate of 5856 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•