Reputation: 19507
I know that base 16 uses the characters [0-9a-f], and base 36 uses [0-9a-z], but what about base 40? Base 50? Base [arbitrary number]? How does php determine what characters to use for high-base numbers?
Upvotes: 2
Views: 82
Reputation: 37365
PHP won't "determine" symbols for just any arbitrary base. Because base_convert()
allows conversions for bases between 2
and 36
only. Thus, it's not allowed to use it for base 50, for example:
Both frombase and tobase have to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35.
I assume that it is about base_convert()
since only this function has direct relation to the question
As for base_convert()
: internally, it will do _php_math_zvaltobase()
call where char map is defined:
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
Upvotes: 4