Closed
Bug 237268
Opened 20 years ago
Closed 19 years ago
parseInt returns 0 for '08' and '09'
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: pwbryan, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 The top-level parseInt function returns 0 rather than 8 or 9 when passed '08' or '09' as an argument. It works as expected for '01' through '07', and as far as I've tested, for any other zero-padded integers (e.g., 0011, 00012, etc.). I know: it's so weird I wouldn't believe it myself if I couldn't reproduce it every time. Reproducible: Always Steps to Reproduce: 1. Open JavaScript console 2. type "alert ( parseInt('08') )" in the input field 3. Hit "Evaluate" Actual Results: Alert window displays 0 Expected Results: Alert window should display 8 parseFloat works as expected. Confirmed bug still present in the following: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040210 Firefox/0.8
Comment 1•20 years ago
|
||
This is invalid. a leading 0 means that the number is an octal, so 8 and 9 aren't valid numbers. test it also in IE: javascript:alert ( parseInt('08') ) If you want them to be parsed as decimal set the proper base: parseInt('08', 10) Invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Comment 3•19 years ago
|
||
Reopening to mark as a dup of bug 43425 (also invalid)
Status: VERIFIED → UNCONFIRMED
Resolution: INVALID → ---
Comment 4•19 years ago
|
||
*** This bug has been marked as a duplicate of 43425 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago → 19 years ago
Resolution: --- → DUPLICATE
Updated•19 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•