Sujet : Re: Number Formatting (was Re: Continuations)
De : johnl (at) *nospam* taugh.com (John Levine)
Groupes : comp.archDate : 19. Jul 2024, 18:46:23
Autres entêtes
Organisation : Taughannock Networks
Message-ID : <v7e8pf$19a8$1@gal.iecc.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
According to Scott Lurndal <
slp53@pacbell.net>:
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
On Wed, 17 Jul 2024 18:42:44 GMT, Scott Lurndal wrote:
>
The problem is that the modern languages don't have a modern concept of
a PICture clause.
>
Perhaps one thing that killed them was they are not localizable?
>
They certainly were localizable, at least with respect to
punctuation and currency symbol. And COBOL is far from 'killed'.
COBOL now has CURRENCY SIGN which lets you set the currency symbol to
edit into a picture, and DECIMAL POINT IS COMMA, to switch the two.
That covers a lot of local currency conventions but not all. Some
countries put the currency symbol before the amount, some after it,
some between the units and the decimals. Some use two decimals, some
three, many use none. Some show negative values with a minus sign,
some with parens around the amount, some other ways.
If you want to do this right, you need a library that can
format all this per country, like this python library:
https://babel.pocoo.org/en/latest/api/numbers.html#babel.numbers.format_currencyIt's certainly possible to do all that in COBOL, but it's painful.
I think the problem with picture clauses is that they while they did
the job, in practice they are mostly used in a few stylized ways, the ones
that the 360's ED and EDMK can handle, and couldn't handle situations
where the subfields are reordered.
I admit printf can't reorder the subfields but many of its modern descendants
like python formats can and often do.
-- Regards,John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",Please consider the environment before reading this e-mail. https://jl.ly