Jump to content

Should'nt This Be FALSE?


Recommended Posts

From the LabVIEW 8.2 Online Help for the And Array Elements function:

"Returns TRUE if all the elements in Boolean array are TRUE. This function also returns TRUE if Boolean array is empty because TRUE is the identity for the Boolean AND operation. Otherwise, the function returns FALSE. This function accepts an array of any size but returns only a single value based on all values in Boolean array. "

I remember asking this question a while back...I think lots of people have asked it in the past, which is probably why that sentence is now in the Help. :)

-D

Link to post
Share on other sites
I'm not convinced, but I'll leave it to the pros to point out why...

There was a famous thread on Info-LabVIEW about this issue...

Maybe it is easier to begin with the numeric array function _Mulltiply Array Elements_ (MULT(A)) which shows a similar behavior: when applied on an empty array, the result is 1 which is the neutral element of the multiplication.

For example if the array A contains N identical elements X then the result MULT(A) is X^N. Then if A is empty a consistent definition for the result is X^0 = 1. This also makes sure that MULT(A|B) (where | denotes array concatenation) always equals MULT(A)*MULT(B) even in the cases where A or B is empty (that wouldn't be true if MULT(empty) was defined to 0).

The same logic applies to boolean AND array elelements. If you want AND(A|B) to be always equal to (AND(A) and AND(B))

AND(A|B) = (AND(A) and AND(B))

Now if B is empty the A|B = A

AND(A) = AND(A) and AND(empty)

which is valid only if AND(empty) = TRUE.

The heart of the argument on Info-LabVIEW was a poster that insisted that since the logical operator 'and' is a binary operator (it operates on two arguments) it didn't make sense to apply it on arrays of 0 or 1 element; the result should be undefined. However AND(A) is a different operator, conveniently defined on arrays, a definition including 0 and 1 element arrays:

AND(A) == 1 and A[0] and A[1] ... and A[N-1]

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.