Skip to content

ilog10

ilog10(n): number

Defined in: packages/core/src/number/integer/ilog10.ts:21

Floor of log₁₀ for a positive integer number value.

Backward-scans the powers of ten below Number.MAX_SAFE_INTEGER — O(19) = O(1).

number

Must satisfy n >= 1; negative / zero / non-integer input is undefined behaviour.

number

Floor of log₁₀(n), i.e. the number of decimal digits minus one.

ilog10(1); // → 0
ilog10(9); // → 0
ilog10(10); // → 1
ilog10(999); // → 2
```;