LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
crossrulz

XOR Array Elements

Status: New

We currently have an AND Array Elements and OR Array Elements.  It would be helpful to also have an XOR Array Elements.  I most often run into needing this when trying to calculate parity.

 

Current Boolean Pallette.PNG


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
7 Comments
AristosQueue (NI)
NI Employee (retired)

XOR says "For two boolean values A and B, if A and B are different, return TRUE, otherwise, return FALSE." Applying that to an array, you're asking for a primitive that returns TRUE if and only if all the elements are true or all the elements are false?

RavensFan
Knight of NI
I think what he wants is a serial XOR of each element, just like doing an XOR with the compound arithmetic function.  An Odd number of Trues returns a True, an Even number returns a False.
AristosQueue (NI)
NI Employee (retired)

Ah. Something like this then:

ArrayXOR.png

Having a picture helps clarify the idea. 

altenbach
Knight of NI

Just to clarify the typical use, operating on boolean arrays is relatively boring. A much more useful application is to use it on integer arrays for bitwise XOR. This is often needed for e.g. checksum calculations. Look at this simple example (posted here) where it would replace the while loop.

 

Of course it should accept arrays of any dimension.

elset191
Active Participant

@altenbach wrote:

A much more useful application is to use it on integer arrays for bitwise XOR.

 


(Or and And Array Elements should also work on integer arrays.)

--
Tim Elsey
Certified LabVIEW Architect
crazywalt77
Member

XOR array.png

Using increment of an integer to measure an XOR for an Array.

wiebe@CARYA
Knight of NI

>Using increment of an integer to measure an XOR for an Array.

 

That doesn't XOR the array, it checks if there's exactly one true value. 

 

The XOR is true if there's an odd number of true's. So in your example, you'd have to use Quotient & Remainder the result with 2, and then do the checks...

 

This would work though:

XOR Array.png