feat(types): BigInt + Decimal exact economy numbers (#52)
Types phase 2 — the "money problem". A splice-on-demand bignum engine (runtime/native/bignum.ludic, self-contained, only intrinsics) exposed as two namespaces: - BigInt.* — arbitrary-precision integer (sign-magnitude, base-1e9 limbs): from/parse, add/sub/mul/pow, div/mod (by int), cmp/eq/is_zero, to_int, str. For idle counters and exact huge currencies that overflow a 32/64-bit int. - Decimal.* — exact base-10 fixed point (BigInt mantissa + decimal scale): from/parse, exact add/sub/mul, cmp/eq, scale/rescale (truncate), str. So 0.10 + 0.20 is exactly 0.30 — no binary rounding. Both exact => deterministic; no f32/f64. Wired: parser splice trigger (g_uses_bignum), emit_call dispatch, reseeded seed, a self-asserting example (examples/library/bignum.ludic + feat_case), and per-symbol docs + inventory. All suites green incl. golden renders byte-identical and the bootstrap fixpoint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
2c9f9ac549
commit
bd6b12d2ea
35 changed files with 23274 additions and 20791 deletions
7
docs/language/bigint/_section.md
Normal file
7
docs/language/bigint/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: bigint
|
||||
title: BigInt
|
||||
order: 10
|
||||
---
|
||||
|
||||
Arbitrary-precision integers with no upper bound, for idle/incremental counters, exact huge currencies, and score arithmetic that a 32- or 64-bit <code>int</code> would overflow. A <code>BigInt</code> is a sign-magnitude number stored as base-1e9 limbs, so every operation is <strong>exact</strong> and therefore deterministic — bit-identical on every platform, with no binary floating point. Build one with <code>BigInt.from</code> (an <code>int</code>) or <code>BigInt.parse</code> (decimal text), combine with <code>add</code> / <code>sub</code> / <code>mul</code> / <code>pow</code> / <code>div</code> / <code>mod</code>, compare with <code>cmp</code> / <code>eq</code> / <code>is_zero</code>, and render with <code>str</code>. Arguments are positional. The runtime is spliced in only when a program mentions <code>BigInt.*</code>.
|
||||
Loading…
Add table
Add a link
Reference in a new issue