/** * Pure fixed-point decimal core for the money descriptor. * * All conversion goes decimal-string ⇄ scaled `BigInt`. There is no * floating-point arithmetic anywhere: a value like `123.45` becomes * `12345n` purely by string manipulation, never by `value * 100` (which * would reintroduce the very drift money() exists to eliminate). BigInt * has no magnitude ceiling, so values past `Number.MAX_SAFE_INTEGER` * stay exact end-to-end. * * This module knows nothing about currencies, descriptors, or storage — * it is the isolated, exhaustively-tested arithmetic kernel. */ export type RoundingMode = 'half-up' | 'half-even' | 'half-down' | 'up' | 'down' | 'ceil' | 'floor'; export type ParseResult = { ok: true; value: bigint; } | { ok: false; reason: 'precision' | 'nonfinite'; }; /** * Parse a decimal (`number | string`) into a scaled `BigInt` at the * given scale. When the input carries more fractional precision than * `scale`: * - `rounding` omitted ⇒ `{ ok: false, reason: 'precision' }` * - `rounding` set ⇒ the tail is rounded per the mode. * Non-finite / unparseable input ⇒ `{ ok: false, reason: 'nonfinite' }`. */ export declare function parseToScaledInt(input: number | string, scale: number, rounding?: RoundingMode): ParseResult; /** * Number of fractional digits in the canonical decimal rendering of * `input` (`'123.45'` → 2, `100` → 0, `'1e-7'` → 7), or `null` when the * input is non-finite / not a decimal. Used to infer the working scale * of arithmetic helpers from their canonical-string inputs. */ export declare function decimalScaleOf(input: number | string): number | null; /** * Re-scale a scaled `BigInt` from `fromScale` to `toScale`. Scaling up * is exact (append zeros); scaling down rounds the discarded tail per * `rounding`. The rounding decision reuses the same kernel as * {@link parseToScaledInt}, so `rescaleScaledInt(parse('1.005', 3), 3, 2)` * and `parse('1.005', 2, mode)` agree for every mode. */ export declare function rescaleScaledInt(value: bigint, fromScale: number, toScale: number, rounding?: RoundingMode): bigint; /** * Render a scaled `BigInt` back to its canonical decimal string at the * given scale. `(12345n, 2)` → `'123.45'`; `(5n, 0)` → `'5'`; * `(-1n, 2)` → `'-0.01'`. Exact for any magnitude. */ export declare function formatScaledInt(value: bigint, scale: number): string;