AutoMeasure Posted September 8, 2016 Report Share Posted September 8, 2016 This looks like a bug to me. Or is it expected behavior using some kind of vector logic? :-) When you run the attached VI, both Boolean LEDs should output False, but one is False and the other is True. I'm running LV 2015 f2. Thanks. -Joe Bug demo of In Range And Coerce.vi Quote Link to comment
hooovahh Posted September 8, 2016 Report Share Posted September 8, 2016 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. Quote Link to comment
AutoMeasure Posted September 8, 2016 Author Report Share Posted September 8, 2016 (edited) 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 September 8, 2016 by AutoMeasure added words Quote Link to comment
shoneill Posted September 9, 2016 Report Share Posted September 9, 2016 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..... 1 Quote Link to comment
Neil Pate Posted September 9, 2016 Report Share Posted September 9, 2016 Totally agree. This behaviour is expected (only since I got burned by it), but very strange indeed. Quote Link to comment
ShaunR Posted September 9, 2016 Report Share Posted September 9, 2016 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..... 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.