MCPcopy
hub / github.com/formatjs/formatjs / pow

Method pow

packages/bigdecimal/index.ts:389–406  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

387 }
388
389 pow(n: number): BigDecimal {
390 if (this._special === SpecialValue.NAN) return this
391 if (n === 0) return new BigDecimal(1)
392 if (n < 0) {
393 return new BigDecimal(1).div(this.pow(-n))
394 }
395 if (this._special === SpecialValue.POSITIVE_INFINITY) return this
396 if (this._special === SpecialValue.NEGATIVE_INFINITY) {
397 return n % 2 === 0
398 ? BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false)
399 : this
400 }
401 if (this._mantissa === 0n) return new BigDecimal(0)
402 const m = this._mantissa ** BigInt(n)
403 const e = this._exponent * n
404 const [nm, ne] = removeTrailingZeros(m, e)
405 return BigDecimal._create(nm, ne, SpecialValue.NONE, false)
406 }
407
408 floor(): BigDecimal {
409 if (this._special !== SpecialValue.NONE) return this

Callers 3

bigdecimal.test.tsFile · 0.80
FormatDateTimePatternFunction · 0.80
decimal-cache.tsFile · 0.80

Calls 4

removeTrailingZerosFunction · 0.85
divMethod · 0.80
_createMethod · 0.80
toNumberMethod · 0.80

Tested by

no test coverage detected