lumbda/www/repl/asm
russell@unturf.com 988c7cbec7
wat bignums (tag 10): closes whitepaper §2.1 — (expt 2 1024) exact on all 3 tiers
Variable-length signed bignums on the asm-wasm tier. Layout:
  [tag=10, sign:i32, n_limbs:i32, limbs[]:u32]
Little-endian u32 limbs (base 2^32). i64 used for limb-pair products
in bn_mul and for the (rem << 32) | limb shift in bn_divmod_small.

Promotion: num_add/sub/mul/cmp inspect operands and pick the right
representation (fixnum, rational, bignum). Fixnum overflow in +/-/* is
detected by computing in i64 and checking against the 30-bit fixnum
range — outside that, operands lift to bignums.

(expt 2 1024) uses exponentiation-by-squaring through num_mul so
intermediate products auto-promote, returning the exact 309-digit value.

Reader: digit parsing accumulates via num_add/num_mul, so a literal of
any length reads as the narrowest representation that holds it.

Parity corpus: KNOWN_DIVERGE is now empty. 237/237 passing across
python (ref), c-wasm, and asm-wasm. New asserts pin the bignum surface
so a regression breaks make wasm-test immediately.
2026-06-14 16:13:33 -04:00
..
lumbda-asm.loader.js playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00
lumbda-asm.wasm wat bignums (tag 10): closes whitepaper §2.1 — (expt 2 1024) exact on all 3 tiers 2026-06-14 16:13:33 -04:00