Closed Bug 414032 Opened 17 years ago Closed 17 years ago

Large integers (2^55) become different values when written as strings

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: vidarhol, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (compatible; Konqueror/3.5; Linux; X11; x86_64) KHTML/3.5.7 (like Gecko)
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.11) Gecko/20080125 Firefox/2.0.0.11

document.write(36028797018963968) writes 36028797018963970  (off by two). Larger integers result in larger errors.


Reproducible: Always

Steps to Reproduce:
1. Put <script>document.write(36028797018963968)</script> on some web page
Actual Results:  
Writes 36028797018963970

Expected Results:  
Should write 36028797018963968

This happens with MSIE and Opera as well, but not Konqueror. Some kind of ES issue?
Yes; numbers in ES3 are floating-point doubles with 52 (53 with the hidden bit, I believe) bits of precision.  Your number is large enough that the imprecision is visible at the integer level; for smaller numbers the difference is less than 1.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.