|
Euan wrote: >Hi, >I am in the process of converting my source from RPG3 to RPG4 and have the >following piece of code. > >RPG3 >add x y > >which translates to >RPG4 >eval x = x + y > >Now RPG3 is forgiving of overflow errors, but RPG4 is not. >How can I trap potential overflow errors? >Can I set a compiler option (in CRTBNDRPG) to show this condition? The ILE RPG IV compiler has no option which will ignore numeric overflow in expressions. You are using a conversion utility which is too aggressive in its conversions. As you have seen, the EVAL doesn't always work the same as the ADD. So, it might be best to disable this particular conversion. I believe most tools have that option. I think the better question is this: Why are you getting the overflow exception? Did you expect truncation in this situation? When designing and implementing ILE RPG IV, we chose to always signal overflow in expressions for several reasons. First, the majority of overflow situations reflect errors in the program. Since expressions can be more complex than fixed format statements, truncation errors would have been more common and harder to debug. Second, it's more difficult to handle truncation meaningfully for integer, unsigned, and float numeric datatypes. (Of course, by default, we kept the old numeric overflow behavior for the decimal data types on old fixed form statements for compatibility.) Hmmm, maybe it IS a good idea to convert all arithmetic to expressions just to see what your program is doing to the data. Perhaps you'd find numeric truncation happening in places you didn't expect? Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.