forth: fix #S / UM/MOD precision bugs — Hayes 628→632/638 (99%)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s

Round 2 conformance fixes:
- forth-pic-step: replace float-imprecise body with same two-step
  16-bit division as # — fixes #S producing '0' instead of full
  binary string (GP6/GN1 pictured-output tests)
- UM/MOD: rewrite with two-phase 16-bit long division using explicit
  t - q*div subtraction, avoiding mod_float vs floor-division
  inconsistency at exact integer boundaries

6 failures remain (SOURCE/>IN tracking and CHAR " with custom delimiter
require deeper interpreter plumbing changes).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 21:31:03 +00:00
parent 32a8ed8ef0
commit aad178aa0f
5 changed files with 342 additions and 187 deletions

View File

@@ -106,6 +106,20 @@ Representation:
_Newest first._
- **Post-phase-6 conformance fixes — Hayes 628→632/638 (99%).** Round 2:
fixed `forth-pic-step` (used by `#S`) to use the same precise two-step
16-bit division as `#`, and rewrote `UM/MOD` using two-phase 16-bit long
division to avoid `mod_float` vs `floor-division` inconsistency at integer
boundaries. Fixes GP6 / GN1 (pictured output), and the UM/MOD remainder bug.
- **Post-phase-6 conformance fixes — Hayes 618→628/638 (98%).** Round 1:
fixed multi-WHILE compiler bug (REPEAT was consuming back-pc instead of
WHILE-target dicts — added `forth-drain-cstack-dicts`); fixed `+LOOP` exit
test by clipping increment to 32-bit signed; rewrote `M*`/`UM*` using
16-bit half-multiply (`forth-umul32`) to avoid float64 precision loss near
2^62; rewrote `#` with two-step division. Eliminated all 6 errors; 10 fails
remain (SOURCE/>IN tracking and CHAR " require deeper plumbing changes).
- **Phase 6 close — JIT cooperation hooks (Hayes unchanged at 618/638).**
Every word record now carries `:vm-eligible? true` and a
`:call-count` counter that `forth-execute-word` bumps on every