Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Converting ~50 significant digits base to base
Posted:
Dec 11, 2010 2:15 PM


Hi, I have made a protocol for "random deal codes" (playing cards), which are in base 36 (numerals and letters). I have a deck with 64 cards, 16 ranks, which requires 46 digits base 36, or 71 digits base 10 to put its entire arrangement into a single code. (This is part of the game culture, and less digits can be used, typed in, or worked with)
I have a problem with how to convert these numbers in computer programming, because they aren't numbers anymore  no processor I know of keeps 71 significant digits. So I am trying to chase this thing bytebybyte.
I start with a 46character string (nonmath). I can grab bytes off of it. I can grab the first one and put it in a number variable, and then grab the next digit and multiply it by 36 and add it in.
Next, I can pull out a digit in base 64 (which I then need to do), and in the end an array of base 64 digits will give me everything I need. I'll use "base36" and "base64" as the names of the arrays of digits, with [] brackets for array indexes (starting at index 1 = least significant). "Buffer" will be a number field for doing mathwork in.
Perhaps I am approaching this in an impossible way (above)? After putting base36[1] + base36[2]*36 into a number ("buffer"), and then producing base64[1] by dividing by 64 to pull a base 64 digit out, then I want to go back to get another base 36 digit. The problem is that I don't know what to multiply it by (it doesn't seem to be 36 again) to add it into the buffer at that point.
I can work with the base36[] number digitbydigit, and I would like to produce base64[] as an array of digits. Can anyone help me to populate the array of base64 digits?
TIA  Mark



