Repository navigation
CobolEdit.format drops high-order digits of a floating-insertion PICTURE: $$$,$$9.99 of 1234.50 -> $$$,$$4.50 #3933
Description
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
#3834 (part 2): lower the gauntlet baseline after #3935 -- 67 left (#…
#3834 (part 2): the Cultural Gauntlet's India slice -- cp1140, rupee …
#3933 / #3910 / #3911: floating currency editing, PICTURE SYMBOL prec…