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



Hmmm.... I think you are correct - Sorry!

In this situation we know the data will never be negative but I agree with
your point.

Yes *HIVAL is what we would use - just used the 999999999's for the
example.

The amount of data is also small so Mult of Sub is not of concern.

Appreciate all the answers

Cheers




From: "John Yeung" <gallium.arsenide@xxxxxxxxx>
To: "Midrange Systems Technical Discussion"
<midrange-l@xxxxxxxxxxxxxxxxxx>
Date: 13/02/2020 07:29 AM
Subject: Re: Sorting an array ascending and descending
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxxxxxxxx>



On Wed, Feb 12, 2020 at 3:51 PM Don Brown via MIDRANGE-L
<midrange-l@xxxxxxxxxxxxxxxxxx> wrote:

Yes we have used that method of 9's compliment previously.

Hmm... this is MIDRANGE-L, not RPG400-L, though this seems like an RPG
question.

RPG has some conveniences for this approach, like *HIVAL (so you don't
have to count out the nines yourself, especially handy if the fields
ever change size). Personally, I still prefer multiplying by -1
instead. Feels a bit more "mathy" and less "computery" (I like mathy).
Moreover, it works even if some of your values are negative. (*HIVAL
minus some negative number will overflow a same-sized field.) Finally,
if you just take the negative, you can make the mental conversion
quicker if you need to visually inspect values.

I don't know if it would be a performance optimization to subtract
from 0, rather than multiply by -1. I know when I first started out in
RPG, the Z-SUB opcode felt to me as though it *ought* to be faster
than MULT (I never tested this; it just *looked* like it must be
related to a hardware-supported instruction, on top of
addition/subtraction generally being faster than multiplication.)

John Y.

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.