Skip to content

det: COMP-1/COMP-2 as IBM hexadecimal floating point; COMP-5 VALUE image (#4271 slice 1) - #4571

Merged
squid-protocol merged 3 commits into
mainfrom
feat/4271-det-float
Oct 6, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
feat/4271-det-float

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4271 (slice 1: COMP-1 / COMP-2). Fixes the value bug of #4501 (see below for why it is not auto-closed).

What

The det translator and runtime now model COMP-1 / COMP-2 as IBM hexadecimal floating point (HFP). Before, every statement that named a float was a Hole.

  • Runtime (cobolrt/Hfp.java, Field.hfp, float branches in Cobol / Codec):
    • Storage: 4 or 8 bytes, big-endian, as z/OS holds them.
    • Arithmetic follows the z/Architecture Principles of Operation. ADD and SUBTRACT keep one guard digit, then truncate. MULTIPLY and DIVIDE truncate the exact result. Long to short uses LOAD ROUNDED.
    • Conversions follow IBM's "Conversions and precision". A float moved to a fixed-point item is rounded, with at most 9 or 18 significant digits. COMP-2 to COMP-1 is rounded.
    • DISPLAY uses IBM's external floating-point form (-.9(8)E-99, -.9(17)E-99).
  • Translator (gen.py): each statement gets IBM's evaluation mode (Appendix A): fixed point, short (all COMP-1, no multiplication) or long. Comparisons are done in floating point. VALUE clauses are encoded by det/hfp.py, the translator's own HFP model.
  • Refused by name (a Hole citing oracle_assumptions.md C6): anything the oracle cannot decide.
    • A float's bytes, or the bytes of an item over it: a group MOVE, a REDEFINES, a reference modification, STRING, a CALL argument, a record, a COMMAREA.
    • A float moved to or from a nonnumeric item, and a comparison with a nonnumeric operand.
    • Exponentiation and intrinsic functions inside a float expression.
    • ON SIZE ERROR, ROUNDED into a float, and DIVIDE REMAINDER in float mode.
    • HFP exponent overflow or underflow, refused at run time.

How the oracle comparison works

GnuCOBOL stores IEEE floats and evaluates float expressions in truncated decimal, so it cannot decide HFP. The slice is proven three ways (test_det_hfp.py, test_det_programs.py):

  1. Byte layout and arithmetic, by hand-computed IBM-cited vectors: 1.0 = 41100000, -118.625 = C276A000, 0.1 = 4019999A, the range ends 7FFFFFFF and 00100000, and the guard digit ("1 - 16**-8 = 1"). The rounding rules and the DISPLAY form are checked the same way.
  2. The Java runtime against the Python model, bit for bit, over a table of conversions, the four operations in both precisions, and float-to-fixed and DISPLAY. These are two independent implementations of the same rules.
  3. Behaviour against GnuCOBOL where it can decide, on values that every format holds exactly. The new FLOAT program (every MOVE direction, the four verbs with and without GIVING, COMPUTE, IF / 88 / THRU / EVALUATE / sign conditions, SET TO TRUE, PERFORM VARYING, INITIALIZE of a group holding a float) matches GnuCOBOL in bytes, typed and typed-groups modes (the typed-mode equivalence).

While writing (3) I found that GnuCOBOL 3.1.2 gets some float expressions wrong. COMPUTE L2 = (L1 - N3) / N4 gives 0. L1 / N4 + S1 * 2 drops the second term. IF S1 + 1 > 2 is false for S1 = 6.25. This is recorded in register C6 as places where the oracle decides nothing.

ASSUMED, because IBM does not document it (register C6): the fixed-to-float conversion (truncated to long, then rounded to short), DISPLAY mantissa rounding, and truncation when a float result is stored in a fixed receiver without ROUNDED.

#4501 (COMP-5 VALUE)

layout.encode_number wrote a COMP-5 VALUE truncated to its PICTURE and big-endian, while the runtime reads COMP-5 little-endian. So S9(4) COMP-5 VALUE 32767 read back as -12534 (2767 byte-swapped). The image now holds the whole value in the runtime's (GnuCOBOL's) order. The new COMP5 program matches GnuCOBOL in all three modes; before the fix it gave -12534 / 12533 / 40725 / -9713144.

The CAXA det port proof: port_runner run --backend det for CAXA and CAXB on the case's generated project, then cics_crucible.py --cases ca-xctl-versions --sides java-ported at the v0.3.0 pin.

So #4501's first acceptance item is met and its second ("length-range passes") is not. I have left the issue open for the orchestrator to close or retitle.

Left for later slices of #4271 (unchanged, register C5 / C7)

  • NUMPROC(PFD) with non-preferred signs: refused by name.
  • ARITH(EXTEND), TRUNC(OPT), INTDATE(LILIAN): detected from CBL / PROCESS cards and refused (UnsupportedOption).
  • COMP-5 in z/OS byte order where its bytes are observable (C7).

mortgage-mpmt stays in the det sweep baseline with an updated reason. Its interest COMPUTE now translates, but the payment's (1 + C) ** N (N with decimal places) is a float exponentiation, the one hole.

Gates

Run on the branch after merging origin/main (#4560, #4563, #4567, #4564): pr_gates.py 7/7 pass (lint, audits, secrets, xray, gauntlet, golden, suite); --ratchets 6/6 pass; det tests 419 pass with EQUIVALENCE_E2E=1 (JDK 17 + docker); proof_sweep.py --det-only --skip-db2 "as expected". Milestone not set (the milestone PATCH is blocked for the agent).

🤖 Generated with Claude Code

https://claude.ai/code/session_017BVJCCUMdjLJq1TAM3V34V

squid-protocol and others added 3 commits October 6, 2026 05:35
…image (#4271 slice 1, #4501)

The det runtime models HFP (cobolrt/Hfp, Field.hfp): big-endian storage, ADD /
SUBTRACT with one guard digit, truncating MULTIPLY / DIVIDE, LOAD ROUNDED long to
short, IBM's float-to-fixed rounding (9 / 18 significant digits) and DISPLAY as
external floating point. The translator picks each statement's mode by IBM's
Appendix A rule (fixed, short, long), compares in floating point, encodes float
VALUEs with det/hfp.py, and refuses by name what GnuCOBOL (IEEE, decimal
evaluation) cannot decide: a float's bytes or those of an item over it, float
exponentiation and functions, SIZE ERROR / ROUNDED / REMAINDER in float mode.

Proof: IBM-cited byte vectors, the runtime against det/hfp.py bit for bit, and a
FLOAT program equal to GnuCOBOL on exact values in bytes, typed and groups modes.

#4501: a COMP-5 VALUE was written truncated to its PICTURE and big-endian while
the runtime reads COMP-5 little-endian (32767 read back as -12534); the image now
holds the whole value in the runtime's order (COMP5 program, against GnuCOBOL).

Part of #4271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR
@squid-protocol squid-protocol added enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist labels Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review October 6, 2026 14:49
@squid-protocol
squid-protocol merged commit f92d45b into main Oct 6, 2026
37 of 39 checks passed
@squid-protocol
squid-protocol deleted the feat/4271-det-float branch October 6, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant