RPGLE Eval div vs. DIV Operation on Calc

I recently changed a piece of coding to free-form.

Field1    DIV    2.250               Result

eval      Result = Field1 / 2.205


The free-form line gets an error - The target for a numeric operation is too small to hold the result when Field1 is 377872, but the original does not.  The Result field is defined as 7.2

Does anyone know why this is, and can the error be avoided?
nickmbnabbAsked:
Who is Participating?
 
DOSLoverConnect With a Mentor Commented:
With Field1=377872, value of Field1/2.205 = 377872/2.205 = 171370.521451... which means 7,2 will not be big enough to hold the result. Please try with result field of 9,2.
0
 
DOSLoverCommented:
The EVAL statement with Half-Adjust should solve your problem:
       eval(h)      Result = Field1 / 2.205 ;
0
 
nickmbnabbAuthor Commented:
I tried that....still get the same error msg.
0
 
nickmbnabbAuthor Commented:
Yes, that did work.  Thank you.  Yet I still wonder why the original non-freeform coding was able to handle the truncating, while the free-form needed the field to be expanded.
0
All Courses

From novice to tech pro — start learning today.