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.
19 KiB
19 KiB