Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)
SCREEN COBOL Source Program
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual—426750-001
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
2. The adjustment of that result for use in further computations