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


  • Subject: Re: Exclusive-or (was: Re: Biton/Bitoff)
  • From: Hans Boldt <boldt@xxxxxxxxxx>
  • Date: Thu, 26 Mar 1998 08:40:24 -0500

Hi Mark!  How to check if exactly 1 out of n conditions is true?  I can't
think of any easy way to do that.  With a bit of analysis, it's clear that
A XOR B XOR C works for all cases except where all three operands
are true.  Generalizing to more conditions, it appears that stringing
together conditions using XOR gives TRUE if the number of TRUE
conditions is odd, FALSE if an even number.  So it looks like some
other technique is needed.  I can't imagine that this would be a
common thing in application programming, but you could write a
RPG IV procedure that takes n char(1) or indicator parameters where
n-1 of them are optional.  The procedure would count the number of
true conditions and return the appropriate indicator value.

Will XOR be added to RPG IV?  About half a year ago, I suggested
that it might be.  However, when I raised the idea in my group, the
response was why bother, since <> provides equivalent function.
So, one way to answer the question is that the language already
has XOR!  But if an explicit XOR is added, it still wouldn't help for
your specific situation.

Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com




owner-midrange-l@midrange.com on 98-03-26 00:04:37
Please respond to MIDRANGE-L@midrange.com
To: MIDRANGE-L@midrange.com
cc:
Subject: Re: Exclusive-or (was: Re: Biton/Bitoff)


Hans,

At 09:16 AM 3/19/98 -0500, you wrote:

>However, if you want to do exclusive-or in a conditional expression,
>you can use the <> operator.  For example, the <> in the following
>statement acts just like exclusive-or:
>
>        IF               (A<17) <> (B=10)
>
>That is, the condition is true only if the results of (A<17) and (B=10),
>are not the same.

 How would you deal with additional condition groups, where you wanted the
expression to be true when only one out of n expressions is true?

 Will XOR make it as an opcode?

 -mark

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@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
+---



+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@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 thread ...

Follow-Ups:

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.