MCPcopy
hub / github.com/formatjs/formatjs / findN2R2

Function findN2R2

packages/ecma402-abstract/NumberFormat/ToRawFixed.ts:27–35  ·  view source on GitHub ↗
(x: Decimal, f: number, roundingIncrement: number)

Source from the content-addressed store, hash-verified

25
26//IMPL: Helper function to find n2 and r2
27function findN2R2(x: Decimal, f: number, roundingIncrement: number) {
28 const nx = x.times(getPowerOf10(f)).ceil()
29 const n2 = nx.div(roundingIncrement).ceil().times(roundingIncrement)
30 const r2 = ToRawFixedFn(n2, f)
31 return {
32 n2,
33 r2,
34 }
35}
36
37/**
38 * https://tc39.es/ecma402/#sec-torawfixed

Callers 1

ToRawFixedFunction · 0.85

Calls 4

ToRawFixedFnFunction · 0.85
ceilMethod · 0.80
timesMethod · 0.80
divMethod · 0.80

Tested by

no test coverage detected