Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Performing arithmetic with numeric fields and constants z/OS DFSORT: Getting Started SC23-6880-00 |
|
Suppose you want to display the results of subtracting the second
PD field in Table 1 from the first PD field in Table 1. As discussed previously, the PD fields are stored
as integers, but we know that:
In order to do arithmetic on these fields, you must ensure that
the integer and decimal parts of the numbers match up correctly.
For example, in the first record, the first PD value is +1524900810
representing +15249008.10 and the second PD value is +20000 representing
+20.000. In order to subtract the second PD value from the first PD
value, you need to put them in the following forms:
You could use the following OUTREC statement to handle the subtraction
correctly:
11,6,PD,MUL,+10 multiples the first PD field by 10 to match up the decimal places. SUB,31,7,PD subtracts the second PD field from the results of the 11,6,PD,MUL,+10 operation. EDIT and SIGNS are used to make the results more meaningful. The results produced for this OUTREC statement are:
You can do arithmetic with numeric fields and decimal constants
(+n and -n) using the operators MIN (minimum), MAX (maximum),
DIV (division), MUL (multiplication), MOD (modulus), ADD (addition)
and SUB (subtraction). The order of evaluation precedence for the
operators is as follows, but can be changed by using parentheses:
You can use p,m,f, MIN, MAX, MUL, DIV, MOD, ADD, SUB, +n, -n and parentheses to do a wide variety of arithmetic operations for various numeric formats. The result of an arithmetic operation is a 15-digit ZD value that can be converted to a different numeric format, or edited using pre-defined edit masks (M0-M26) or user-defined edit masks, as discussed earlier. For complete details on arithmetic operations, see z/OS DFSORT Application Programming Guide. |
Copyright IBM Corporation 1990, 2014
|