Skip to content

Decimal

Decimal = object

Defined in: packages/math-numbers/src/decimal/decimal-types.ts:17

An exact base-10 value, stored as coefficient × 10^exponent.

This is the arithmetic layer for arbitrary-precision decimal: plain data plus free functions, each taking the DecimalContext that decides how many significant digits to keep and which way to round. That is the same shape as the soft-float kernel — sfAdd(a, b, format) — for the same reason: the operation depends on a descriptor, and threading the descriptor through the call is cheaper and clearer than storing it on every value.

Invariant: the coefficient carries no trailing zeros, so a value has one canonical representation and precision is the digit count of the coefficient. Zero is 0 × 10⁰ with precision one.

coefficient: bigint

Defined in: packages/math-numbers/src/decimal/decimal-types.ts:18


exponent: number

Defined in: packages/math-numbers/src/decimal/decimal-types.ts:19


precision: number

Defined in: packages/math-numbers/src/decimal/decimal-types.ts:22

Significant decimal digits in coefficient.