× 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 Mon, Dec 9, 2013 at 1:44 PM, Dave Shaw <daveshaw@xxxxxxxxxxxxx> wrote:
num4 = %dec(%subst(%char(num6):1:4):4:0);

I'm not sure it's more readable at a glance, but if you read through
it, I think [it documents the intention].

Fully agree here. Well, I'd say it's definitely NOT more readable at
a glance. ;) But it does document the intention.

I'm not sure how it'll perform, but it can't be worse than division.

It absolutely can be worse than division. Division is one arithmetic
operation. Yes, it's the most expensive of the four basic arithmetic
operations, but modern hardware usually is pretty quick at arithmetic.
%CHAR by itself is already potentially more expensive than a
division. You have to convert a number to a variable-length string,
and you have to put the decimal in the right place, if there is one.
Then you have to convert in the other direction with %DEC.

There's a lot of logic in generic conversion between numbers and
strings. (Some specialized conversions are faster than others. Zoned
format lends itself to quicker conversion on the i. MOVE-type
"conversions" are comparatively fast, because they have minimal logic
to them.) Arithmetic is almost no logic - usually just a single
hardware instruction.

John

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.