LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (9/11/2009) - Compound Arithmetic

A public service announcement for today, "Compound Arithmetic".  I try to remember to use this function when I sit down and just start wiring up a formula.  It can really improve the readability and editability (is that a word?) of many formulas.  For instance compare the following simple example

 

CompoundArithmetic.png 

 

Not only does it look better already, inevitably I will need to add an operation in the middle which will either require manual shifting or making space on the BD which often moves a lot more things than I would like.  My only gripe with this function is that the inversion dots can be a little hard to see sometimes and there is plenty of space in the terminal area to provide a better indication. 

 

As usual VIOTD groundrules are here

Message 1 of 5
(3,202 Views)

Also, not only can the inputs be inverted, but so can the output.

 

It works for the multiply mode as well by doing a division instead of multiplication.  Or on the output, it is a reciprocal.

 

Of course for AND, OR, XOR, inversion means applying the NOT function to it.

 

What is interesting is that you can do an XOR on more than 2 inputs.  I never thought about that possibility before.  What is the result of XOR'ing multiple booleans?  It looks like if an odd number of booleans are true, then the result is true.  If an even number of booleans are true, than the output is false.  I wonder what a practical use of that function would be.

Message 2 of 5
(3,184 Views)

Ravens Fan wrote:

 

What is interesting is that you can do an XOR on more than 2 inputs.  I never thought about that possibility before.  What is the result of XOR'ing multiple booleans?  It looks like if an odd number of booleans are true, then the result is true.  If an even number of booleans are true, than the output is false.  I wonder what a practical use of that function would be.


I believe that the inverse Gray code is found from a cascade of XORs, is that practical?

 

0 Kudos
Message 3 of 5
(3,179 Views)

it can be made to be practical lol:)

Message Edited by Harold Timmis on 09-11-2009 11:30 AM
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 4 of 5
(3,177 Views)

Ravens Fan wrote:

...

What is the result of XOR'ing multiple booleans?  It looks like if an odd number of booleans are true, then the result is true.  If an even number of booleans are true, than the output is false.  I wonder what a practical use of that function would be.


I believe that is called a "half-adder". A "half-adder" does the math for adding two boolean bits. The third bit is the "Carry-in" from next least significant bit.

 

 

So if you are adding 1 plus 1 and have a carry-in of 1 then the result for that digit is 1 with a carry-out to the next more significant bit. If you chain enough of these together along with other stuff, and you have an ALU.

 

Ben

 

 

 

 

 

Message Edited by Ben on 09-11-2009 10:45 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(3,170 Views)