bigIntLog10
bigIntLog10(
n):number
Defined in: packages/core/src/big-int/log10.ts:31
Floor of log₁₀ for a positive bigint.
Algorithm (O(log log n)):
- Compute the bit length of
n. - Approximate
t = ⌊bitLength × kOneOverLog2Ten / 2^63⌋. - Correct by +1 if
n >= 10^(t+1).
Parameters
Section titled “Parameters”bigint
Must satisfy n >= 1n; negative / zero input is undefined.
Returns
Section titled “Returns”number
Floor of log₁₀(n) as a number.
Example
Section titled “Example” bigIntLog10(1n); // → 0 bigIntLog10(10n); // → 1 bigIntLog10(10n ** 38n - 1n); // → 37 bigIntLog10(10n ** 38n); // → 38 ```;