× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On Friday, February 27, 2004, at 07:21 AM, Bob Cozzi wrote:


There is nothing wrong with using the "MULT 10000.01" technique in RPGIII. I
do it every time I need to convert a date in that old language.

It was always a dumb idea--even in RPG III. It causes an arithmetic exception every time it is used. Exceptions hurt performance.


It is obscure because it relies on arithmetic truncation present in RPG but not present in other languages (and also not present in EVAL).

It is obscure because it is not immediately obvious from the code what is happening. The first time anyone sees the MULT trick they either ask someone and accept the answer "It converts the date format" or they work it out on paper to see what happens. Either approach indicates the technique is not obvious. The result is programmers who perpetuate a bad habit because they don't understand what it is doing. They are just familiar with it. A case of "That's how we've always done it".

If you use it in RPG IV, then you are right it is a questionable choice.
The only other technique in RPG III is to use a data structure, but that can
be a bit more complex that the MULT. If you haven't seen it before then it
doesn't matter which one you use because the person maintaining the code
after you will have to deal with it, so just be sure to document it
properly.

Data structure moves are much more obvious, especially if decent variable names are used. Three obvious MOVE statements are not more complex than one obscure MULT operation. The moves are also much faster. Test both techniques some time and see for yourself.


While doing a few conversions per host interaction may not cause a noticeable performance impact using the same trick on a large database file with many dates will. Much better to be consistent and use the faster AND more obvious approach everywhere.

The MULT trick falls in the category of clever (read stupid) programming tricks and should be avoided--especially by people who teach others.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.