Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RPGLE Eval div vs. DIV Operation on Calc

Posted on 2013-06-01
4
Medium Priority
?
485 Views
Last Modified: 2013-06-04
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?
0
Comment
Question by:nickmbnabb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:DOSLover
ID: 39213114
The EVAL statement with Half-Adjust should solve your problem:
       eval(h)      Result = Field1 / 2.205 ;
0
 

Author Comment

by:nickmbnabb
ID: 39214230
I tried that....still get the same error msg.
0
 
LVL 5

Accepted Solution

by:
DOSLover earned 2000 total points
ID: 39215101
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
 

Author Comment

by:nickmbnabb
ID: 39215860
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

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question