Skip to content

ROUNDED semantics: no fact or porting rule says ROUNDED = half away from zero; ROUNDED MODE discarded; inputs never hit ties #3825

Closed

Description

@squid-protocol

What: COBOL ROUNDED rounds half away from zero. Probe: 2.5 → 3, −2.5 → −3; ROUNDED MODE NEAREST-EVEN gives 2.

  • The only arithmetic rule a porter sees says truncation with RoundingMode.DOWN. Nothing maps ROUNDED to HALF_UP, or warns against HALF_EVEN (banker's rounding) and Math.round (wrong on negatives).
  • Intermediate precision (ARITH COMPAT/EXTEND) differs between GnuCOBOL and IBM. Plausible, not probed.

Where:

  • cobol_to_java_port_tickets.py:46-50.
  • gitgalaxy/core/data_moves.py:101: _NOISE includes ROUNDED and MODE.
  • equivalence_inputs.py never aims at .5 ties.

Test: COMPUTE R ROUNDED = A / B, and a ROUNDED MODE NEAREST-EVEN variant, with inputs forced to exact ties both positive and negative. Expected: 3 / −3 / 2.

Fix:

  • A per-statement rounding fact (mode, SIZE ERROR present).
  • A porting rule mapping each ROUNDED MODE to a RoundingMode.
  • A tie-seeking input generator.
  • An IBM intermediate-precision caveat in the report.

Found by a cultural-assumptions audit (2026-09-26): confirmed in code or by probe (JDK 17 locales, IBM code-page decoding, the harness's GnuCOBOL image) unless marked plausible.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    on Sep 26, 2026
  2. added 3 commits that reference this issue on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions