Skip to content

CobolEdit.format drops high-order digits of a floating-insertion PICTURE: $$$,$$9.99 of 1234.50 -> $$$,$$4.50 #3933

Closed

Description

@squid-protocol

Found by the Cultural Gauntlet's executed JVM layer (#3834 part 2, python tests/tools/cultural_gauntlet.py --run).

What: the generated CobolEdit.format(pic, value, decimalComma, currency) (entity/vsam/CobolEdit.java, from cobol_to_java_repository_forge.py) renders a floating-insertion PICTURE with the insertion characters left in place and the high-order digits DROPPED -- silently, no exception:

PICTURE value COBOL (the $ row run under GnuCOBOL 3 -std=ibm; £ / ₹ by the same single-character rule) CobolEdit.format
$$$,$$9.99 1234.50 $1,234.50 $$$,$$4.50
£££,££9.99 (CURRENCY SIGN '£') 1234.50 £1,234.50 £££,££4.50
₹₹₹,₹₹9.99 (CURRENCY SIGN '₹') 1234.50 ₹1,234.50 ₹₹₹,₹₹4.50
III,II9.99 (CURRENCY SIGN 'INR ' WITH PICTURE SYMBOL 'I') 1234.50 the string 'INR ' floated before 1,234.50 (IBM; not verified here: GnuCOBOL lacks multi-character signs) III,II4.50
KK,KK,KK9.99 ('Rs' WITH PICTURE SYMBOL 'K') 1234.50 'Rs' floated before 1,234.50 (IBM; not verified here) KK,KK,KK4.50

The class's own Javadoc says "Floating insertion strings ($$$9, ---9) are not handled: port those by hand", but it neither refuses them nor says so at runtime, and the port ticket's rule tells porters to render edited fields "only through CobolEdit.format". A floating currency sign is THE common way to write a money field, so a port that follows the rule prints 4.50 for 1,234.50. It is locale-independent (identical under hi-IN, en-IN and en-US JVMs); the Z / 9 / . , paths are right (ZZ,ZZ,ZZ9.99 gives 12,34,567.89 and ZZZ.ZZ9,99 with DECIMAL-POINT IS COMMA gives 1.234,50, as COBOL does).

Also: a PICTURE SYMBOL (I, K, U) is emitted as a literal letter; only $ is replaced by currency.

Fix direction: implement floating insertion ($ / currency symbol / + / - strings: the leftmost symbol is the sign position, the rest are digit positions, the symbol floats to just left of the first significant digit), with the PICTURE SYMBOL substituted by the currency string; until then throw UnsupportedOperationException for a floating string rather than return wrong digits.

Ledgered: *|runtime-run cells of plain, currency_pound, currency_euro, currency_rupee, rounded_nearest_even, intdate_lilian in tests/cultural_gauntlet/baseline.txt (edited (default): want ' $1,234.50', got '$$$,$$4.50'); they leave the baseline when this is fixed (--full --run --update-baseline). The multi-character dialects (EUR/U, INR/I, Rs/K) have no declared value yet -- GnuCOBOL does not implement a multi-character currency string -- add one with the fix.

🤖 Generated with Claude Code

Activity

  1. added
    bugUnintended behavior or logic failure in the engine
    legacy-modernizationCOBOL refractor, dead-code extraction, and JCL forging
    priority: highCore feature broken, but workarounds exist
    on Sep 27, 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

    bugUnintended behavior or logic failure in the enginelegacy-modernizationCOBOL refractor, dead-code extraction, and JCL forgingpriority: highCore feature broken, but workarounds existstatus: pending-releaseMerged to main, awaiting PyPI version bump

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions