The basic encoding of N is quite effective if N is a power of 2, since then conversion between groups of a fixed size of digits and a fixed size of bytes can occur.
Base64: 2 6 - 6 bits per digit, therefore 4 digits = 24 bits = 3 bytes.
Otherwise, school multiplication must occur along the entire length, resulting in the calculation of "BigInteger".
a bit faster than, for example, multiplying / dividing by base N many times, has an array of degrees N.
To encode a byte array for digits, you can use N 0 N 1 N 2 N 3 , ... in the form of byte arrays of shorter or equal length and repeated subtractions.
As byte signs, short may be more appropriate. Say, if the high byte of a number is 98, and the smaller N-power is 12, then about 7 is a digit.
The same permissions can be used to decode the digits into a byte array.
Good luck.
source share