Error de punto flotante al sumar en JavaScript

VERIFIED INVALID

Status

()

Core
JavaScript Engine
VERIFIED INVALID
16 years ago
16 years ago

People

(Reporter: Alejandro Vidal Quiroga, Assigned: rogerl (gone))

Tracking

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
El error ocurre cuando se suman estos valor.

Comment 1

16 years ago
What build ID of Mozilla are you using? Please include that in any bug report. 
I am using Mozilla trunk binary 2002072508 on WinNT.


                   javascript:alert(266.91+548.22)

                   Moz --> 815.1300000000001
                   NN4 --> 815.1300000000001
                   IE6 --> 815.1300000000001


All three browsers do this, because computer arithmetic is not done
in base 10, it is done in base 2. Certain numbers which have finite
decimal expansions in base 10 have infinite decimal expansions in
base 2. That, plus the fact that the computer must round off infinite
representations to finite ones, produces the results above.

This result will be the same in any language that follows the
ISO standard 16262 (ECMAScript) and the ANSI/IEEE standard 754.
You will find the same behavior in most other programming languages,
including Java and almost all implementations of C/C++.

Marking invalid -
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID

Comment 2

16 years ago
Marking Verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.