Page 1 of 1

parseInt("08") returns NaN

PostPosted: Mon Sep 16, 2013 10:32 pm
by cl@muc
Hello,

the funtion calls
Code: Select all
parseInt("08"); // returns NaN
and
parseInt("09"); // returns NaN
both return NaN.

The funtion call
Code: Select all
parseInt("07"); // returns 7
returns the correct value: 7.

So this obviously seems to be a bug.

Does anybody else have this problem?

Thanks,
Christoph

Re: parseInt("08") returns NaN

PostPosted: Tue Sep 17, 2013 12:12 am
by peterbliskavka
Yes.

Also, parseInt("008") and parseInt("009") return 0.0, and parseInt("0008") parseInt("0009") also return 0.0.

parseInt("0019") returns 1.0..... weird.

Re: parseInt("08") returns NaN

PostPosted: Tue Sep 17, 2013 5:03 am
by david
parseInt makes assumptions when leading zeros are present and the radix is not specified. Specifically with the version of Rhino Servoy is using octal is assumed.

https://developer.mozilla.org/en-US/doc ... s/parseInt