MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / digitCount

Method digitCount

src/big-decimal/big-decimal.ts:171–176  ·  view source on GitHub ↗

* Number of decimal digits in |significand|, computed once and cached on this * immutable value. `toPrecision`, `cmp`, `div`, `pow`, `ln` etc. all re-derive * the order of magnitude from the (unchanging) significand; caching turns the * O(log n) bigint `bigintDigits` count into an O(1) reus

()

Source from the content-addressed store, hash-verified

169 * @internal
170 */
171 _digitCount(): number {
172 // The frozen static constants pre-seed `_digits` (see their definitions), so
173 // the cache-write below is only ever reached on non-frozen, mutable
174 // instances — no `Object.isFrozen` guard needed on this hot miss path.
175 return this._digits ?? (this._digits = bigintDigits(this.significand));
176 }
177
178 constructor(value: string | number | bigint | BigDecimal) {
179 if (value instanceof BigDecimal) {

Callers 10

cmpMethod · 0.95
mulToPrecisionMethod · 0.95
divMethod · 0.95
divTowardMethod · 0.95
sqrtTowardMethod · 0.95
powMethod · 0.95
toPrecisionMethod · 0.95
decimalExponentFunction · 0.80
transcendentals.tsFile · 0.80

Calls 1

bigintDigitsFunction · 0.90

Tested by

no test coverage detected