Pathway/iTS SCREEN COBOL Reference Manual (H06.10+, J06.03+)

SCREEN COBOL Source Program
HP NonStop Pathway/iTS SCREEN COBOL Reference Manual426750-003
2-17
Evaluation of Expressions
The three examples that follow illustrate the division operation.
Example 1
A normal divide computation proceeds as follows:
03 A1 PIC S9(9)V9(9) VALUE 2.
03 A2 PIC S9(9)V9(8) VALUE 3.
03 AR PIC SV9(9).
:
DIVIDE A1 BY A2 GIVING AR.
where:
____________
3.00000000 | 2.000000000
is computed as:
000000000.666666666
000000003.00000000 | 2.00000000000000000
then moved to AR as:
.666666666
Example 2
Here is a second example:
03 A1 PIC S9(2)V9(9) VALUE 2.
03 A2 PIC S9(2)V9(8) VALUE 3.
03 AR PIC SV9(9).
:
DIVIDE A1 BY A2 GIVING AR.
where:
____________
3.00000000 | 2.000000000
is computed as:
000000000.666666666
03.00000000 | 02.0000000000000000
then moved to AR as:
.666666666
When a division operation in an arithmetic expression involves a COMPUTE statement
or a relational expression, the intermediate results are evaluated in two steps:
1. The actual division
Note. If (I1+D2+DR) is greater than 18, the low-order digits of the quotient are lost; in other
words,any part of the quotient less than the following number is lost: 10 ** (I1+D2+DR-18)