When trying to understand how base58check works, in the referenced implementation by bitcoin, when calculating the size needed to hold a base58 encoded string, it used following formula:
// https://github.com/bitcoin/libbase58/blob/master/base58.c#L155
size = (binsz - zcount) * 138 / 100 + 1;
where binsz
is the size of the input buffer to encode, and zcount
is the number of leading zeros in the buffer. What is 138 and 100 coming from and why?