|A base 36 numbering scheme should be the math rappresentation of a normal numer expressed with 36 different ciphers.
It should be quite an easy task to create a function that converts the strings that you have to plain binary numbers (base 2) understandable to the computer. This function is equivalent to an ascii to bin conversion, only the symbols that have top be handled are 36.
The sequence, I suppose, is: 0 1 2 3 4 5 6 7 8 9 A B C D E F G . . . . . Z
The generic rappresentation of a number expressed in base x is:
Vn*X^n + V(n-1)*X^n-1 + V(n-2)*X^n-2 + ... + V(0)
In plain the sum of all ciphers by the power of the base at the position taken as exponent.
This is sample to convert a base 36 number to a base 2 numberEDIT: This sample converts any ascii rappresentation of a number in all bases between 2 and 36. It acts as the standard atoi, atol, etc. It converts all applicable characters up to the end of string or the first non number with respect to the choosed base. If the first string char is not a valid cipher, or the string is empty it returns NULL.
long long GenRadVal(char *str, int base)
if (base<2 || base>36)
long long val = 0;
for (int i = 0; str[i]; i++)
int c = toupper(str[i]);
if ((c < 0) || ((c > '9') && (c < 'A')) || (c > 'Z'))
c = c > '9' ? c - 'A' + 10 : c - '0';
if (c >= base)
val *= base;
val += c;
This will give you back a 64 bits number equivalent to the string. To go back to the original value you can use itoa() function in C.
Now comparisons are easy..
P.S. the reverse for this function is the stdlib function itoa() with base=36.
modified 17-May-15 12:01pm.