Tracy Pierce wrote:
[snip]
> But for HP Cobol, it's my understanding and experience that
intermediate
> results are never kept to any greater precision than any of the
operands
> is capable of storing. But I'd be hard pressed to find that
accurately
> and clearly documented, despite an attempt made in the Cobol II/XL
> manual under COMPUTE.
My advice: If you like the economy of expression that COBOL arithmetic
expressions provide, and don't like to write long words like ADD,
SUBTRACT, MULTIPLY, and DIVIDE, and if your code will always be compiled
with HP COBOL II, feel free to use arithmetic expressions. Be sure you
understand the rules for precision of intermediate results, which are
documented in the COBOL II/XL Reference Manual, especially if you use
division.
However, if you'd like your code to give the same answers when compiled
with other COBOL compilers and run on the HP-3000 or other platforms, it
might be worth the effort to write a few extra lines of code. Avoid
arithmetic expressions and the COMPUTE statement when possible.
Unlike other languages, such as C and Java, the COBOL language does not
define the details of how arithmetic expressions are evaluated. Hence
arithmetic expressions in COBOL are not portable.
Walter
Walter J. Murray
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|