Home The Company Publications Products Links Tips Jobs

Numeric Variables & Computation Statements

Last update: 18 May 2005

Question

What are people's experiences with regards efficiency when comparing the use of Integer and Packed format variables as counters, indices, or other such fields?

Answers

From Jim Wisdom and Dieter Storr
  1. Use I definitions for indices.
  2. Use packed for any Natural math. I format is better for integer math in general
  3. Continue to use numeric (N format) for any strictly to-display fields.
An added fact often missed:

If any 'numeric' fields are on Adabas files that are used for arithmetic reasons, define them as packed for the DDM (easy if you use Predict). This way, you eliminate data conversion by Adabas when it provides the data contents on==in the record buffer. I have too often seen where people define them as D format. Thus means:

  1. Adabas re-format,
  2. Natural conversion for math.
  3. Natural re-convert if these fields are part of WRITE/DISPLAY/PRINT statements.
This can represent a lot of saved conversion work.

Example

Executed the following program with 16 format combinations. Each format combination ran 10 times. See the results.
0010 DEFINE DATA LOCAL                   
0020 1 #SUM       (P9) INIT <1>          
0030 1 #INCREMENT (P9) INIT <1>          
0040 1 #LIMIT     (P9) INIT <100000>     
0050 * For #SUM and #INCREMENT           
0060 * Format combination: P9, N9, I4, F4
0070 END-DEFINE                          
0080 ST. SETTIME                         
0090 REPEAT UNTIL #SUM > #LIMIT          
0100   ADD #INCREMENT TO #SUM            
0110 END-REPEAT                          
0120 DISPLAY *TIMD(ST.)                  
0130 END                                 
ADD #INCREMENT
P9
#INCREMENT
N9
#INCREMENT
I4
#INCREMENT
F4
#SUM P9 2.0 2.7 3.6 7.2
#SUM N9 3.1 3.2 3.7 6.9
#SUM I4 5.7 12.6 3.0 6.0
#SUM F4 5.8 5.6 6.6 4.7

Top Page



Back to NATURAL Tips, Tricks, Techniques -- Overview