Ensuring Accuracy

  • The length of any field specified in an arithmetic operation cannot exceed 63 digits. If the value being assigned to the field exceeds 63 digits, digits are dropped from either or both ends, depending on the location of the decimal point.
  • The TRUNCNBR option (as a command parameter or as a keyword on a control specification) determines whether truncation on the left occurs with numeric overflow or a runtime error is generated. Note that TRUNCNBR does not apply to calculations performed within expressions. If any overflow occurs within expressions calculations, a run-time message is issued. In addition, TRUNCNBR does not apply to arithmetic operations performed in integer or unsigned format.
  • Half-adjusting is done by adding 5 (-5 if the field is negative) one position to the right of the last specified decimal position in the result field.
  • The half adjust entry is allowed with the following operations:
    • Arithmetic operations, but not with an MVR operation or with a DIV operation followed by the MVR operation.
    • The EVAL and FOR-EACH operations, when the target field is numeric.
    • The RETURN operation, when the returned value is numeric.
    • The DATA-INTO and XML-INTO operations. For these operations, half adjusting affects assignments to numeric fields or subfields.
    • The CHAIN, DELETE, READE, READPE, SETGT, and SETLL operations when a list of search arguments or %KDS is specified. See Keys for File Operations.
  • Half adjust only affects the result if the number of decimal positions in the calculated result is greater than the number of decimal positions in the result field. Half adjusting occurs after the operation but before the result is placed in the result field.
  • Half adjust is does not affect float fields.
  • Resulting indicators are set according to the value of the result field after half-adjusting has been done.