Skip to content

IntegralFractional

IntegralFractional = object

Defined in: packages/math-numbers/src/integral-fractional.ts:25

Decomposition of a real number into its sign, integral part and fractional digits, without loss:

value = s × (i + f × 10^−fracDigits)

This is the positional view of a decimal: the digits either side of the point, exactly as written. Decimal’s { coefficient, exponent } is the scaled-integer view of the same number — better for arithmetic, since adding two of those is one integer add plus exponent bookkeeping. Neither replaces the other; convert with DecimalNum.toIntegralFractional.

fracDigits is carried rather than derived from f, because f alone cannot tell 0.7 from 0.007 — both have f = 7n. It is also what preserves trailing zeros, so 1.50 decomposes with fracDigits: 2 and keeps its two decimal places.

// −123.4560 → { s: -1, i: 123n, f: 4560n, fracDigits: 4 }
// 0.007 → { s: 1, i: 0n, f: 7n, fracDigits: 3 }
// 42 → { s: 1, i: 42n, f: 0n, fracDigits: 0 }
```;
## Properties
### f
> **f**: `bigint`
Defined in: packages/math-numbers/src/integral-fractional.ts:31
Non-negative fractional digits, read as `f × 10^−fracDigits`.
***
### fracDigits
> **fracDigits**: `number`
Defined in: packages/math-numbers/src/integral-fractional.ts:33
How many decimal places `f` occupies, including any leading zeros.
***
### i
> **i**: `bigint`
Defined in: packages/math-numbers/src/integral-fractional.ts:29
Non-negative integral part — the digits before the decimal point.
***
### s
> **s**: `-1` \| `1`
Defined in: packages/math-numbers/src/integral-fractional.ts:27
Sign of the number: `-1` or `+1`. By convention, zero uses `s = 1`.