×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




It is possible that the parseInt routine is using the rather obscure
concept that numbers starting with a "0" digit are supposed to be octal.
To test this, you might try parsing "010" and see if you get ten or
eight.

Ah heck, I'll do it myself... (pause for a quick test) ...and yes, it
seems to be the case!

var s = "07";
alert(s + " = " + parseInt(s));
s = "08";
alert(s + " = " + parseInt(s));
s = "10";
alert(s + " = " + parseInt(s));
s = "010";
alert(s + " = " + parseInt(s));

I get the following:

07 = 7
08 = 0
10 = 10
010 = 8

Gotta love octal.  So, in order to parse properly, you have to remove
any leading zeros.

Joe

> From: Cromar, Graham
> 
> Turns out, the only values that don't parse properly (in the range 1 -
31)
> are '08' and '09' which result in num being zero. '01' thru '07'
result in
> a 1 and 7 respectively.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.