Skip to content

det: FUNCTION NUMVAL in a floating-point expression as IBM's long HFP -- CBSA BNK1CAC / BNK1TFN / BNK1UAC whole (Part of #4270) - #4742

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4270-numval-float
Oct 9, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4270-numval-float

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4270. Makes CBSA's BNK1CAC, BNK1TFN and BNK1UAC translate whole: their only gap was COMPUTE <COMP-1 / COMP-2> = FUNCTION NUMVAL(...), refused as "FUNCTION NUMVAL in a floating-point expression (oracle_assumptions.md C6)". BNK1CRA loses the same two holes and keeps EXEC CICS INQUIRE.

IBM semantics modelled (register C6)

  • NUMVAL: "The returned value is a floating-point approximation of the numeric value represented by argument-1. The precision of the returned value depends on the setting of the ARITH compiler option" (Enterprise COBOL 6.4 Language Reference, SC27-8713-03, NUMVAL, p. 605). "NUMVAL, NUMVAL-C and NUMVAL-F return long (64-bit) floating-point values in compatibility mode, and return extended-precision (128-bit) floating-point values in extended mode" (6.4 Programming Guide, SC27-8714-03, "Converting to numbers", p. 115).
  • So NUMVAL / NUMVAL-C in a float expression is a long HFP operand (Hfp.numval): the statement is long (IBM, Appendix A p. 800: short only if all receivers and operands are COMP-1 items), and a COMP-1 receiver rounds the long result to short (LOAD ROUNDED, already modelled). A float MOVEd on to fixed point rounds, as already modelled.
  • The digits go to long HFP as any fixed-point value does: truncated, the existing ASSUMED conversion.
  • Refused by name at run time: an argument of more than 18 digits ("must not exceed 18" under ARITH(COMPAT)), and a value of more than 15 digits counted from the first nonzero one ("At most 15 decimal digits can be converted accurately ... Otherwise, the result may lose precision in an unexpected manner", p. 115).
  • ARITH: read through the options resolver (program.arith_extend, the same effective_with_defaults as TRUNC and NUMPROC). Under ARITH(EXTEND), every floating-point expression is refused by name, because extended-precision HFP is not modelled. CBSA is COMPAT (IBM default; no card sets ARITH).
  • Other intrinsic functions in a float expression stay refused.

Where the oracle differs (declared in C6)

GnuCOBOL computes NUMVAL in decimal, stores the nearest IEEE float, and truncates a float MOVEd to fixed point. Measured on cobc 3.1.2 (2026-10-08):

  • NUMVAL('0.7') into a COMP-1, then to 9(4)V99: cobc gives 0.69; det (IBM rounding) gives 0.70.
  • NUMVAL('12.34') into a COMP-2, then to 9(10)V99: cobc gives 12.33; det gives 12.34.

The two agree only on values exact in both formats, such as 1.5, 2.25 or 100.50. No CBSA case runs these programs yet.

Proof

  • test_det_programs.py NUMVALF vs cobc (EQUIVALENCE_E2E=1), bytes / typed / groups modes, all pass. It covers the CBSA shapes: a COMP-1 and a COMP-2 receiver, a AMTI(1:AMTL) argument, a leading sign, a trailing CR, NUMVAL-C with $ and commas, zero, two NUMVALs added, a NUMVAL comparand, and the < 0 / > 9999.99 / = ZERO tests and MOVEs to fixed point that follow. FLOAT, DPCOMMA, SORTCS and SORTPC also pass (15/15).
  • test_det_hfp.py: Hfp.numval against the model (0.1 gives long 4019999999999999, short 4019999A), the two run-time refusals, the ARITH(EXTEND) refusal from a PROCESS card, and the hole test now uses SQRT. 39 passed.
  • det_port.py check vs origin/main: 78/79 ports unchanged. Only mortgage-mpmt changed (its copy of Hfp.java). proof_sweep.py --det-only --cases mortgage-mpmt: "as expected" (KNOWN_UNPROVEN: its float exponentiation).
  • Census (cics_census.py blockers, CICS programs): whole programs went from 82 to 85 of 125: BNK1CAC (387 to 389 of 389 statements), BNK1TFN (347 to 349 of 349), BNK1UAC (439 to 441 of 441). The NUMVAL gap row is gone. No other program changed, burned or non-burned.
  • evidence.py status --ci: no blocking stale record.
  • pr_gates.py --fast: 5/5 pass. --ratchets: 7/7 pass.

Follow-up: #4741. NUMVAL in a fixed-point COMPUTE is still computed as an exact decimal, but IBM evaluates it in long HFP too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D

…'s long HFP (Part of #4270)

IBM: NUMVAL returns "a floating-point approximation of the numeric value represented
by argument-1" (6.4 Language Reference, NUMVAL); NUMVAL, NUMVAL-C and NUMVAL-F "return
long (64-bit) floating-point values in compatibility mode" (6.4 Programming Guide,
"Converting to numbers"). The det runtime now makes NUMVAL a long HFP operand
(Hfp.numval): the statement is long, a COMP-1 receiver rounds to short. Refused by
name at run time: an argument past 18 digits (invalid under ARITH(COMPAT)) and a value
past 15 significant digits (IBM: precision lost "in an unexpected manner").
ARITH(EXTEND), from the options resolver (program.arith_extend), refuses every
floating-point expression: extended-precision HFP is not modelled.

CBSA BNK1CAC, BNK1TFN and BNK1UAC now translate whole (census 82 -> 85 / 125);
BNK1CRA keeps EXEC CICS INQUIRE. Register C6 declares where the oracle differs
(inexact values: GnuCOBOL truncates a float MOVEd to fixed point). #4741 follows up
NUMVAL in a fixed-point COMPUTE.

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

github-actions Bot commented Oct 9, 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 9, 2026 03:13
@squid-protocol
squid-protocol merged commit 72d2863 into main Oct 9, 2026
39 checks passed
@squid-protocol
squid-protocol deleted the fix/4270-numval-float branch October 9, 2026 03:13
squid-protocol added a commit that referenced this pull request Oct 9, 2026
…e checked (Fixes #4741) (#4759)

* det: FUNCTION NUMVAL / NUMVAL-C in a fixed-point COMPUTE as IBM's long HFP, its store checked (Fixes #4741)

IBM evaluates an arithmetic statement with a numeric-function operand in floating point
(6.4 Programming Guide SC27-8714-03, "Floating-point evaluations", p. 62), and NUMVAL /
NUMVAL-C return long floating point (p. 115; Language Reference SC27-8713-03, p. 605). The
det translator now makes such a statement a long HFP one (Hfp.numval: the same refusals as
#4742 for more than 18 digits and more than 15 significant digits).

IBM documents the float-to-fixed MOVE (rounded) but not an arithmetic statement's store, so
Hfp.fixedStore refuses by name a value the documented and the assumed (truncated unless
ROUNDED) rules store differently, e.g. NUMVAL('0.10') = 0.0999... into 9V99; values exact at
the receiver's scale store as they are and agree with the oracle (NUMVALX, in three modes).
A proven case with such values declares "numval_fixed_store": "oracle" (a declared
difference of its evidence record, #4051): CardDemo COTRN02C (carddemo-tranadd) needs it for
an amount like 123.45 and a 16-digit card number. Register C6 records the semantics, the
refusals and the oracle difference. Census: 108 / 179 programs whole before and after.

Also fixes det_survey's NameError (ispf_screens) when an estate fails to generate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D

* det: refresh the coverage ledger for carddemo-tranadd (its case declares the NUMVAL store, #4741)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D

* carddemo-tranadd: the invalid-card scenario uses a 15-digit value; re-prove the record and ledger (#4741)

NUMVAL of 9999999999999999 (16 significant digits) is undefined on z/OS (long HFP keeps 15)
and refused by name; the scenario's card is now 0999999999999999, still absent from the
cross-reference (same 18/18 paragraphs, 72/75 branches).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D

* det: re-prove carddemo-tranadd and refresh the coverage ledger after merging main (#4741)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D

* det sweep ledger: re-measured the 4 ports #4741 moves after the main merge

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant