× 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.



Bob Cozzi wrote:
Actually Hans, that's not it at all.
If I have a display file with one or two date fields in it (and we're
talking RPGIII here) I would rather write two MULT and get it done than
worry about setting up a DS in RPGIII and moving the bytes around. If I were reading say 100,000,000 database records and converting a date
field in them, then I would probably use the DS method.
-Bob

Bob: You might find this hard to believe, but I think I've changed my mind on this issue.


First, consider performance. Sure, doing a couple of subfield moves is faster than using the MULT trick. But the MULT trick is still ~35 times faster than doing things the proper way, converting to and from a date value!

Second, and perhaps more importantly, consider code readability. Sure, seeing a MULT by 100000.0001 (or whatever) is cryptic. But so is a sequence of moves. Sure, not everyone knows the "trick". But when it's explained, it just becomes another idiom in the language. Much of what a programmer does involves learning and mastering language idioms.

That's not to say I will recommend the use of the MULT date conversion trick. But I agree with you - I really don't see any reason not to use it either when appropriate if you can't do the "right" thing and use the date datatype.

BTW, out of curiosity, I did a bit of performance comparison as I was putting this note together. Here are the times for equal iterations of alternative statements:

#  time  statement
-  ----  --------------------------------------------------
1: 6982: dmdy = %dec(%date(dymd:*iso):*usa);
2: 1038: dmdy = %int(%subst(%char(dymd)+%char(dymd):5:8));
3:  190: C     dymd          mult      10000.0001    dmdy
4:   64: ds.num = dymd;
         ds = %subst(ds:5:4) + %subst(ds:1:4);
         dmdy = ds.num;

Statement #1 is the date conversion done "properly" using conversion to and from date type. Statement #2 sort of does the MULT trick but using character manipulation in a free-form calc. Statement #3 is the MULT trick. #4 converts the date using manipulation of DS subfields.

Clearly, using date data type is the slowest. But also, it would appear that the MULT trick isn't nearly as bad relative to subfield moves as it used to be.

Cheers! Hans


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.