Closed Bug 160173 Opened 22 years ago Closed 22 years ago

Error de punto flotante al sumar en JavaScript

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: as1, Assigned: rogerl)

References

()

Details

El error ocurre cuando se suman estos valor.
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
Closed: 22 years ago
Resolution: --- → INVALID
Marking Verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.