(n: number)
| 32 | |
| 33 | /** Return 10^n as a bigint, memoized for n <= POW10_CACHE_MAX. */ |
| 34 | export function pow10(n: number): bigint { |
| 35 | if (n <= POW10_CACHE_MAX) { |
| 36 | let v = _pow10Cache.get(n); |
| 37 | if (v === undefined) { |
| 38 | v = 10n ** BigInt(n); |
| 39 | _pow10Cache.set(n, v); |
| 40 | } |
| 41 | return v; |
| 42 | } |
| 43 | return 10n ** BigInt(n); |
| 44 | } |
| 45 | |
| 46 | /** Bit length of |n| (the number of bits in its binary representation). */ |
| 47 | export function bitLength(n: bigint): number { |
no test coverage detected