The performance of your program is affected by the data type, size and alignment of the data items. Using the correct data type increases efficiency, particularly in arithmetic operations.
Use unsigned COMP-5 or COMP-X numeric data items; preferably COMP-5 (where possible).
COMP-5 usage is defined for binary storage with the value stored in the native byte sequence of the processor. This makes it ideal for arithmetic efficiency. However, it is not suitable for data stored in files or passed to other machines over a network as the data is not accessible by programs running in an environment in which COMP-5 is stored in a different sequence. In these cases use COMP-X.
In native code programs, it is more efficient to move integer data items that are not COMP-X or COMP-5 to COMP-5 data items before doing arithmetic operations on them.
The speed in which data items are processed varies according to the type of data item.
Addition and subtraction on non-integer data items is fastest if the items are COMP-5 and the decimal alignment is the same in both.
Mixing different data types in the same statement is less efficient than using the same data types throughout. The main exception to this is mixing COMP-5 and COMP-X items, where there is very little impact on performance.
Use only numeric items that occupy one, two, four or eight bytes of storage.
The fastest and smallest code is produced for operations on items that contain up to nine digits, or four bytes for binary items.
Operations on numeric items that contain more than nine digits, or more than four bytes for binary items, produce the slowest and largest code.
Align items on even-byte boundaries, in general.
Do not redefine COMP-5 items to access individual bytes. If access to individual bytes is required, use COMP-X.
Use edited items only when necessary and use only simple ones such as ZZ9. If possible, use them in a subroutine so that the total number of edited moves in your program is kept to a minimum.