Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ParseInt("000008") returns 0.

Posted on 2004-04-15
5
Medium Priority
?
291 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

610 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