HP3000-L Archives

February 2006, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Walter Murray <[log in to unmask]>
Reply To:
Walter Murray <[log in to unmask]>
Date:
Sun, 12 Feb 2006 16:16:39 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (37 lines)
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 *

ATOM RSS1 RSS2