MCPcopy Create free account
hub / github.com/effect-app/libs / normalize

Function normalize

repos/effect/packages/effect/src/BigDecimal.ts:195–222  ·  view source on GitHub ↗
(self: BigDecimal)

Source from the content-addressed store, hash-verified

193 if (self.normalized === undefined) {
194 if (self.value === bigint0) {
195 self.normalized = zero
196 } else {
197 const digits = `${self.value}`
198
199 let trail = 0
200 for (let i = digits.length - 1; i >= 0; i--) {
201 if (digits[i] === "0") {
202 trail++
203 } else {
204 break
205 }
206 }
207
208 if (trail === 0) {
209 self.normalized = self
210 }
211
212 const value = BigInt(digits.substring(0, digits.length - trail))
213 const scale = self.scale - trail
214 self.normalized = makeNormalizedUnsafe(value, scale)
215 }
216 }
217
218 return self.normalized
219}
220
221/**
222 * Changes a `BigDecimal` to the specified scale.
223 *
224 * **When to use**
225 *

Callers 4

[Hash.symbol]Function · 0.70
formatFunction · 0.70
toExponentialFunction · 0.70
isIntegerFunction · 0.70

Calls 2

makeNormalizedUnsafeFunction · 0.85
BigIntInterface · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…