Strange javascript error in parseInt Hello

Axel Richter

 

 

HI,

the function parseInt(string, radix) has a second parameter radix, see http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/toplev.html#1064173.

If there is a leading zero in the string, the radix defaults to octal (8). In octal system there are only numerics from 0 to 7. So "08" is 0, "09" is 0 and "010" is 8 ;-).

Set the radix parameter to 10 if you like to have decimal numbers.

alert(parseInt(num, 10));

greetings

Axel

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact