Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a Java radix limit?

Tags:

java

I noticed that the max limit for a radix in Java is base 36. Is this an arbitrary limit, or does Java have reason for limiting the radix in this way?

like image 310
Adam Avatar asked Nov 12 '11 17:11

Adam


3 Answers

It's the number of decimal digits (10), plus the number of letters in the alphabet (26).

If a radix of 37 were allowed, a new character would have to be picked to represent the 37th digit. While it certainly would have been possible to pick some character, there is no obvious choice. It makes sense to just disallow larger radixes.

like image 92
Mark Byers Avatar answered Nov 01 '22 23:11

Mark Byers


Very simple: 26 letters + 10 digits = 36.

In order to represent a number, traditionally digits and Latin letters are used.

like image 42
Vlad Avatar answered Nov 01 '22 22:11

Vlad


For completeness, I would add that there are two constants defined in JDK:

Character.MIN_RADIX
Character.MAX_RADIX
like image 31
AlexV Avatar answered Nov 01 '22 23:11

AlexV