Take the 2-minute tour ×

The second parameter of parseInt() defines the base to which the first parameter is parsed to. I have been playing around with some numbers and found out that I do not get a correct answer anymore if the base is larger than 36:

parseInt("1", 36);
// -> 1

parseInt("1", 37);
// -> NaN

Is there a limit? And why is it 36?

I was using chrome when I ran my tests

share|improve this question
You answered your question, it is 36. And it is a radix, not base. –  epascarello Nov 5 '12 at 15:11
@epascarello There is also the question "And why is it 36?" –  Ian Nov 5 '12 at 15:11
add comment

4 Answers

up vote 11 down vote accepted

36 is 10 + 26. There are 26 letters in the alphabet, plus 0-9. That's the maximum radix you can use.

share|improve this answer
add comment

The ECMAScript specification specifies the maximum radix as 36.

  • There are 10 digits: (0-9)
  • There are 26 characters: (a-z)
10 + 26 = 36

It should also be mentioned that it would be possible to support a radix higher than 36. The spec could be adjusted to use case-sensitive characters for a radix >36, say 37-62. Special characters, such as with symbols and accented letters could be used.

The reason that they're not, is that it's ambiguous, and unnecessary. Parsing algorithms for custom radixes shouldn't be too difficult, and could be written on an as-needed basis.

Limiting the radix to 36 helps balance performance with utility.

share|improve this answer
add comment

The maximum is 36, because that's the amount of digits and chars the standard alphabet has (0123456789abcdefghijklmnopqrstuvwxyz). If you wonder about anything else like this, you might want to bookmark the official ECMAScript language specification, it's all there

share|improve this answer
add comment

It is 36 because the string representation uses 0-9 plus the alphabet for any extra digits. 10 + 26 = 36.

share|improve this answer
add comment

Your Answer


