Ted Ashton ([log in to unmask]) wrote:
[description of a result that is off by .01 when using FUNCTION SUM]
: Could someone spare a moment to explain to me what's going on here? I thought
: COBOL was "the language which wouldn't lose pennies" !
I'll assume you are using COBOL II/iX. The SUM function is using
floating-point for its intermediate values, and there is no automatic
rounding when the result is assigned to the receiving operand of the
COMPUTE. For best results, use the ROUNDED phrase with the SUM function
when dealing with non-integers.
For further information, see page 10-5 of the reference manual,
"Precision of Numeric Functions," and page 3-26 of the programmer's
guide, "Coding Heuristics when Calling COBOL Functions."
Walter Murray
Hewlett-Packard
Support Technology Lab
COBOL II/iX Project