Jump to content

Bug in In Range And Coerce function?


AutoMeasure

Recommended Posts

I was always cautious when using the aggregate compare mode because I didn't fully understand what it meant.  Reading through the documentation it seems it should work the way you described.

Quote

In Compare Aggregates mode, comparison functions return a single Boolean result after comparing the elements in an array. Comparison functions compare elements sequentially until a decision can be made, much like the alphabetical ordering of English words, where letters of each word are compared until they are not equal. Therefore, the function performs the following steps to determine the result of the comparison:

  • The function compares corresponding elements in each input array, starting at the beginning of the array.
  • If the corresponding elements are not equal, the function stops—it returns the result of this comparison.
  • If the corresponding elements are equal, the Comparison function processes the next pair of values, until it finds an inequality or reaches the end of one of the input arrays.
  • If all values in the input arrays are equal but one array has extra elements at the end, the longer array is considered greater than the shorter one. For example, a Comparison function considers the array [1,2,3,2] to be greater than the array [1,2,3].
Note  The In Range and Coerce function behaves differently than other Comparison functions in Compare Aggregates mode because it requires three inputs. After comparing the first set of elements, the function processes the next set of values only if all three inputs, upper limit, lower limit, and x, are equal. Otherwise, the function returns the result of comparing the first set of elements.

 

Link to comment

It looks like, via some sort of twisted logic, the function is behaving as designed.  See the KnowledgeBase article:

http://digital.ni.com/public.nsf/allkb/BBB794BDCDE0B763862571D4007A0AA5

If the first element of the array is between the first elements of the lower and upper limit arrays, then the function returns True for 'In Range?', amazingly ignoring the remainder of the array.

Quote

The following pseudo code describes the behavior of In Range and Coerce in aggregate mode:

Start at the first element in the array or cluster

        1.  Check to see if the value is in range
        2.  If the value is in range (not including the upper or lower limit) return TRUE, else go to step 3
        3.  If the value is equal to the upper limit goto step 4, else step 6
        4.  Move to the next element
        5.  If the element is equal to the upper limit, go to step 4           
             else if the element is less than the upper limit, return TRUE
             else if the element is greater than the upper limit return FALSE
        6.  If the value is equal to the lower limit go to step 7, else you should not be on this step
        7.  Move to the next element
        8.  If the element is equal to the lower limit, goto step 7
             else if the element is greater than the lower limit, return TRUE
             else if the element is less than the lower limit return FALSE

 

 

Edited by AutoMeasure
added words
Link to comment
1 hour ago, shoneill said:

So it's not a bug in the node per se but a bug in the mind of the person who thought this is how it should operate.....:blink:

It's specmanship by a designer that never uses the end result.

If you read the docs, it talks about clusters and the behaviour is the common denominator. It makes it a little bit useful for clusters  while pretty much useless for anything else.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.