In COBOL, COMP, and COMP-3 data types play a critical role. To handle all numerical calculations, it is a general practice of using COMP and COMP-3 Data types. Explained two super ideas on how to use these data types correctly in your program.
1. Always use an odd number of digits in a COMP-3 field
Since the COMP-3 field is stored as a single digit in a nibble (half of the byte), with one nibble consuming the space for the sign, we know that every time we reference an even number digit COMP-3 field, the compiler has to generate (scratchpad and instructions) code to strip out the high order digit that we don’t use.
2. Whenever possible, always manipulate Numerics of the same format
If you are adding a COMP field to a COMP-3 then the compiler needs to convert one to the other format before the add can take place.
More unnecessary instructions and more scratchpad wasted. So, always use the same type of data types while using the MOVE statement.