LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compound arithmetic XOR fault

I have wired three True Booleans to a compound arithmetic XOR, the result should be false, it is returning a true result!
0 Kudos
Message 1 of 4
(4,643 Views)
Hi John,

this is expected behaviour and written somewhere in the help/manual:
Compound Arithmetic works 'sequentely' like this: (input1 XOR input2) XOR input3.
In your case:
(True XOR True) XOR True = (False) XOR True = True

Added: See the detailed help for the 'Compound artihmetic'. There's a paragraph on XOR operation!


Message Edited by GerdW on 03-23-2007 02:09 PM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(4,639 Views)

As an alternative, if you want a function that returns a true value only when one of the booleans in your array is true. Then that is the same as determining if an integer is power of 2.

 

A positive integer is a power of two if ( x AND (x-1) ) equals zero.

 

Note that this formula incorrectly indicates that 0 is a power of two, so we need to make sure that x is NOT 0.

 

 XOR-Array.png

 

(Tip: If you are using LabVIEW 2009 you can save this VI snippet in your computer and drag it into your code 😉 )

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 3 of 4
(4,367 Views)

John007 wrote:
I have wired three True Booleans to a compound arithmetic XOR, the result should be false, it is returning a true result!

Why would you expect 3 Trues XORed together to be False?  What definition are you using?

 

My understanding of XOR with multiple inputs is that the result is True if there are an odd number of Trues, and the result is False if there are an odd number of Trues.

0 Kudos
Message 4 of 4
(4,347 Views)