Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Using the Eval statement in RPG IV

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using the Eval statement in RPG IV

    I've been asked to write a statistical analysis program for our R & D department. The program requires me to use fields that have 16 decimal positions. We don't normally use RPG IV, but RPG III won't allow me to have a field with more than 9 decimal positions. I wrote a simple program to use as a test. I have three fields, PACK1, PACK2, and PACK3. Each are defined as 30 positions with 16 decimal positions. My eval statement is as follows: EVAL(H) TOTAL = ((PACK1 / PACK2) + PACK3)) TOTAL is defined the same as the other fields. When the program is compiled, it gives an error *RNF7551, which says "Result of numeric operation is truncated to 0 decimal places." Does anyone know why? I've changed the code to reflect old RPG III conventions, and that works. But if we are going to use RPG IV, we should be able to use the EVAL statement. Any help would be greatly appreciated.

  • #2
    Using the Eval statement in RPG IV

    In RPG IV, the intermediate results computed by the EVAL operation assume that digits to the left of the decimal point are more important than digits to the right and since the largest result allowed is 30 positions, truncation can occur during the computation. Your particular computation could theoretically have 90 digits to the left of the decimal point and 48 to the right! The specific way to override this is to use EVAL(r) which tells the operation to never reduce the number of decimal positions below that of the result field. The global way to override this is to specify an "H" spec: H ExprOpts(*ResDecPos) Chris

    Comment


    • #3
      Using the Eval statement in RPG IV

      Worked like a charm! Thanks for your quick response.

      Comment

      Working...
      X