Closed
Bug 454271
Opened 17 years ago
Closed 17 years ago
Leading zero causes incorrect results from javascript:parseInt()
Categories
(Firefox :: General, defect)
Tracking
()
People
(Reporter: jnsears, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1
parseInt("-0321"); // returns -209
parseInt("0321"); // returns 209
parseInt("-0421"); // returns -273
parseInt("0421"); // returns 273
Reproducible: Always
Steps to Reproduce:
1. Execute javascript containing alert(parseInt("-0321"));
2. ???
3. Profit!!!
Actual Results:
An alert box containing -209
Expected Results:
An alert box -321
Comment 1•17 years ago
|
||
No, it's correct. A number that starts with 0 is an *octal* number, not decimal. 321 octal = 209 decimal.
See bug 43425 comment 3 for an explanation and an easy fix.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•