prePEP: Decimal data type

Steve Williams stevewilliams at
Sun Nov 2 06:00:53 CET 2003

John Roth wrote:

> Part of the reason why COBOL has the separate operators
> is that the *destination* of the operation specifies how the
> result is computed. You can't do that with intermediate
> results if you use expression notation.

Ah well, it's Saturday night, I've had a glass of wine, and so I post on 

Assert:  Bob Bemer's PICTURE clause (supremely platform independent) is 
the dreaded static data type.

You can write 1000 lines of COBOL arithmetic using + - * / and get 
consistent results based on the PICTURE of the target and the ROUNDED 

You can even sit down with the end user (she who is uninformed as to the 
wonders of real analysis, but who holds your career in her hands) and 
discuss and markup the program listing.  Even if she doesn't know the 
difference between / and //.

Moreover, most COBOL compilers accept any PICTURE clause as a source.  Viz:

	03  Amount Pic $$$,$$$,$$9.99

	Compute Amount = Units * Unit-Cost

	Compute Total-Amount = Total-Amount + Amount

	Divide Days into Amount Giving Amounts-Per-Day Rounded

You want precision?  Voila: Pic $,$$$,$$$,$$9.9999.

(Forgive me, computer scientists, for the use of the nasty verbs--that's 
just COBOL).

Instead, we discuss separate operations for integers, rationals, reals, 
complex, quaternions, octionions and 'money'--"To infinity and beyond."

I've written Python functions where I pass in a target picture along 
with operands.   But then it was on Saturday night, and I had a glass of 

More information about the Python-list mailing list