2 ms·
The COBOL syntax for that looks like PICTURE IS $-999,999.99 which defines a signed money value represented in decimal. If you print that value, it will b
by Animats 1y ago
The COBOL syntax for that looks like
PICTURE IS $-999,999.99
which defines a signed money value represented in decimal. If you print that value, it will be formatted as requested.
There are a few other formatting characters. A "CR" at the end will cause negative numbers to be printed with "CR" (Credit) at the end.
A "Z" causes lead zero suppression. "*" causes lead zeros to be replaced with asterisks, for check-writing.
Numeric display formatting is an attribute of the data.
That concept, and built-in support of money-like values, has been lost in later languages. In Rust you can have implicit Display or Debug functions for types, although it's mostly used for debugging.
- rbanffy 1y ago> Numeric display formatting is an attribute of the data Mixing value and presentation wasn’t the brightest idea. In their defence, everything was new at the time, and everywhere they were breaking new ground.