Over the last few days, I have been dealing in detail with numbers and number ranges, as well as with the conversion of a value into different number ranges.
[X] Some information:
I got a dataField that includes an specific amount of dataBlobs (int N like e.g 10 or 102, ...).
Every single dataBlob can hold 16 different combination options.
I got a dataString like "102" or "10101010" I want to encode in the data field.
The amount of unique characters in dataString will be the baseValue I'm encoding from.
( If dataString is like"101010101"[2 unique chars "1", "0"] I will encode dataString from base 2 into base 16)
( If dataString is like"102"[3 unique chars "1", "0", "2"] I will encode dataString from base 3 into base 16)The encoding of the dataString into Base16 will give back a array like
["0", "15", "4", "7", "1", "1", ...](all values between 0 and 15) and for every element in theencodedDataI will add one Blob with the specific dataValue (see in the image below)
[X] My question:
I'd like to calculate the maximum length of the dataString a dataField with N dataBlobs(16combinations) can hold.
What is given:
- The maximum amount of dataBlobs can used (N)
- The count of unique chars in dataString ( = the base-value I will encode from)
dataString = "10101010" | (from BASE 2 to BASE 16) will get [10, 10] --> Needs 2x dataBlobs
dataString = "102" | (from BASE 3 to BASE 16) will get [6] --> Needs 1x dataBlob
dataString = "2143567908" | (from BASE 10 to BASE 16) will get [7, 15, 12, 4, 4, 0, 2, 4] --> Needs 8x dataBlobs
How can I calculate the
amount of charactersdataString (with a given Base value) can hold if I want to useNdataBlobs?

In general, the number of digits used to encode a nonnegative integer number $k$ in base $b$ is equal to $ \left \lceil\log_b k \right \rceil + 1$. For instance, to encode 32 in base 2, you need $\lceil \log_2 32\rceil + 1 = 5 + 1 = 6$ digits: $32_2 = 100000$.
If you want to use $N$ dataBlobs, you can encode a number that is at most equal to $16^N - 1$. It follows then that using base $b$ you will need a dataString at most $\left\lceil \log_b \left(16^N -1\right)\right\rceil + 1$ characters long.