Closed Bug 43425 Opened 25 years ago Closed 25 years ago

parseInt ERROR with leading zeros (08 and 09 give incorrect values)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: Lanivdw, Assigned: rogerl)

References

Details

From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) BuildID: 2000033112 parseInt give the wrong result for "08" and "09". Reproducible: Always Steps to Reproduce: 1.Use of parseInt Function 2. Wrong Result only if 08 and 09 is the input value 3. Actual Results: Alert Box: 0 Expected Results: Alert Box: 8 <HTML> <HEAD> <TITLE> TEST</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <Script language="JAVASCRIPT"> alert(parseInt("07")); alert(parseInt("08")); alert(parseInt("09")); </Script> </BODY> </HTML>
Confirming. Changing Platform and OS to ALL as also a bug on Mac OS 8.6/ 2000061411.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 98 → All
Hardware: PC → All
I can comfirm that this bug is on 1. NetScape6 PR1 (Win98 OS & MAC OS 8.6) >>>> (Thanx to qaz2@usa.net for Testing done on MAC OS 8.6) 2. Netscape4.73 (Win98 OS) 3. IE 5 (Win 98 OS) Regards Lani van der Walt E-Mail: Lanivdw@bigfoot.com URL: www.lani.co.za
Sorry for the delay - taking over QA for the JavaScript Engine group - I'm afraid I have to mark this as invalid. The ParseInt() function treats a first argument beginning with "0" as an octal number, not base 10. Thus, the only valid digits for numbers beginning with "0" would be 0-7. A good reference for the parseInt() function is page 186 of the following: "Javascript: The Definitive Guide (Third Edition), by David Flanagan (O'Reilly 1998) Notice that parseInt() also accepts a second argument, which you can use to specify the base you want to use. Using this, parseInt("08", 10) = 8 parseInt("09", 10) = 9
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
*** Bug 181017 has been marked as a duplicate of this bug. ***
*** Bug 220523 has been marked as a duplicate of this bug. ***
*** Bug 235606 has been marked as a duplicate of this bug. ***
*** Bug 270169 has been marked as a duplicate of this bug. ***
Status: RESOLVED → VERIFIED
URL: -
Priority: P3 → --
Summary: parseInt ERROR. 08 and 09 chars gives a incorrect value back. → parseInt ERROR with leading zeros (08 and 09 give incorrect values)
*** Bug 307182 has been marked as a duplicate of this bug. ***
*** Bug 237268 has been marked as a duplicate of this bug. ***
*** Bug 337255 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.