Half Adjust(Column 53) [ HP RPG/iX Reference Manual ] MPE/iX 5.0 Documentation
HP RPG/iX Reference Manual
Half Adjust(Column 53)
The half adjust field rounds numeric data when it is placed in the Result
Field. Do not half adjust alphanumeric fields or use half adjusting with
the MVR operation or with a DIV operation followed by an MVR operation.
Table 8-22. The Half Adjust Field
---------------------------------------------------------------------------------------------
| | |
| Column 53 | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| H | Half adjust data. |
| | |
| blank | Do not half adjust data. |
| | |
---------------------------------------------------------------------------------------------
Half adjusting is only performed when the Result Field has fewer decimal
positions that the result of the operation. Half adjusting is performed
by adding 5 (or -5 for negative numbers) to the most significant digit
that will be truncated. The sum is then truncated to fit in the Result
Field.
Example
Figure 8-48 shows how to half adjust the result of an ADD operation. The
sum of 50 and the number in DATAN is rounded to fit into the field RESULT
which contains 2 decimal positions. Assuming that the sum is 325.5769, 5
is added to the digit 6 (most significant digit to be truncated). The
sum becomes 325.5819. This rounded sum is stored in the field RESULT as
325.58.
________________________________________________________________________________
| |
| 1 2 3 4 5 6 7 |
| 678901234567890123456789012345678901234567890123456789012345678901234|
| _______________________________________________________ |
| |
| C 50 ADD DATAN RESULT 52H |
| |
| |
| |
________________________________________________________________________________
Figure 8-48. Using the Field Length and Half Adjust Fields
MPE/iX 5.0 Documentation