Integer/Alphanumeric Converter
not ratedIt was made for savesystems, and makes an integer need less digets. If you just use I2S() it is easy to see how the system works, and my converter often can save some digets.
Int2Alphanumeric(int, charmap) (string)
Returns the passed integer as a string. If the charmap is longer, the returned string will be smaller. Don't use any letter or number twice in the charmap. The returned string often has less digets than the passed integer.
Alphanumeric2Int(str, charmap) (integer)
for what you need to make a number needing less digets, if you can't get the number from it again? The string returned by the function above, must be passed to this function with the same charmap, to get the number passed to the function above.
If the charmap is "0123456789ABCDEF" the converter returns the passed number in hex. If the charmap is "01" it returns the number in binary.
I'll try to explain how it works. usually, we count from 0 to 9, start from 0 again, while the next digit increases by one, as the first one did before. when that digit reaches the number after 9, it also restarts from 0, while the next digit increases by one. this script counts in the same way, but it counts in ONE digit, until the length of the charmap is too small.
To calculate the biggest number, that can be saved with x digits, and a charmap with an length of y, we have y^x-1. if the charmap has e.g. 64 digits, that can be a very big number, with only a few digits ;)
IMPORTANT!! NEEDS MY IndexOfSubstring FUNCTION!
Int2Alphanumeric(int, charmap) (string)
Returns the passed integer as a string. If the charmap is longer, the returned string will be smaller. Don't use any letter or number twice in the charmap. The returned string often has less digets than the passed integer.
Alphanumeric2Int(str, charmap) (integer)
for what you need to make a number needing less digets, if you can't get the number from it again? The string returned by the function above, must be passed to this function with the same charmap, to get the number passed to the function above.
If the charmap is "0123456789ABCDEF" the converter returns the passed number in hex. If the charmap is "01" it returns the number in binary.
I'll try to explain how it works. usually, we count from 0 to 9, start from 0 again, while the next digit increases by one, as the first one did before. when that digit reaches the number after 9, it also restarts from 0, while the next digit increases by one. this script counts in the same way, but it counts in ONE digit, until the length of the charmap is too small.
To calculate the biggest number, that can be saved with x digits, and a charmap with an length of y, we have y^x-1. if the charmap has e.g. 64 digits, that can be a very big number, with only a few digits ;)
IMPORTANT!! NEEDS MY IndexOfSubstring FUNCTION!