MCPcopy
hub / github.com/formatjs/formatjs / ceil

Method ceil

packages/bigdecimal/index.ts:432–452  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

430 }
431
432 ceil(): BigDecimal {
433 if (this._special !== SpecialValue.NONE) return this
434 if (this._mantissa === 0n) return this
435 if (this._exponent >= 0) return this // already an integer
436
437 const divisor = bigintPow10(-this._exponent)
438 const m = this._mantissa
439 let q = m / divisor
440
441 // Ceil: round toward +infinity
442 // For positive numbers with remainder, add 1
443 if (m > 0n && m % divisor !== 0n) {
444 q += 1n
445 }
446
447 if (q === 0n) {
448 return BigDecimal._create(0n, 0, SpecialValue.NONE, false)
449 }
450 const [nm, ne] = removeTrailingZeros(q, 0)
451 return BigDecimal._create(nm, ne, SpecialValue.NONE, false)
452 }
453
454 log(base: number): BigDecimal {
455 if (this._special === SpecialValue.NAN) return this

Callers 5

bigdecimal.test.tsFile · 0.80
findN1E1R1Function · 0.80
findN2E2R2Function · 0.80
findN2R2Function · 0.80
generateFilesFunction · 0.80

Calls 3

bigintPow10Function · 0.85
removeTrailingZerosFunction · 0.85
_createMethod · 0.80

Tested by

no test coverage detected