Solved

ParseInt("000008") returns 0.

Posted on 2004-04-15
5
286 Views
Last Modified: 2006-11-17
Dear all,

Can anybody tell me why parseInt("000007") returns 7, but parseInt("000008") returns 0, and parseInt("000011") returns 9? Do I need to write a function that strips the leading zero's? If so, does anybody have this function to hand?

Many thanks,

Ben.
0
Comment
Question by:webtechy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 250 total points
ID: 10833017
because if you begin a number with 0 it is parsed as an octal (base 8)

try this:  parseInt("000008",10)

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10833023
... which specifies the base as 10
0
 
LVL 2

Author Comment

by:webtechy
ID: 10833072
Excellent, thanks :-)
0
 
LVL 8

Expert Comment

by:HaydnH
ID: 10833129
0
 
LVL 2

Author Comment

by:webtechy
ID: 10833146
Thanks HaydnH, a favourite site of mine that - after knightEknight's comment I went there myself to take a look :-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question