This statement is wrong. The link is not even related; I assume you meant to instead link to this function in that code — notice how what it does is approximating
When you have
x = 10 ** 500, and want to print it in a readable form, you don't cut
precision digits; you cut
d = (log10(x) - precision) digits and append
"E"+d. For example with
precision = 5 the output would be
"100000E495" (or some other form of the same, like
"100000 * 10**495"). You may also cut trailing zeros, but you can only do that after cutting
d excess digits, for which you need to know
Repeated division is just a silly way of reimplementing logarithm. You could get fancy a use binary search to find the
d, which is slightly more efficient and complicated way of reimplementing logarithm.
Yes, "find first set" would help reimplementing floored
log10 more efficiently. "count leading zeros" only makes sense for fixed-width integers, not for BigInt.
Question is: why should everyone who wants to stringify large BigInts need to reimplement