03-22-2012 02:07 PM
Can I perform and equal comparison between doubles when I use either the upper limit or lower limit compared to the coerced output when the input value is not within the range? (In range and coerce function)
I tried a little experiment with this idea and it seems to work fine but...even though I like and respect Ben I really don't want to have to figure out how to contribute a nickle to his retirement fund.
Solved! Go to Solution.
03-22-2012 02:15 PM
If you are refering to me as "Ben" then don't worry, retirement is covered already. I am just working for fun now.
I did not follow your question so could you post an image to help us understand, please?
I suspect you already know that you can right-click the limits and choose "Include Upper Limit" and that floating point equals are rare in the real world.
Take care,
Ben
03-22-2012 02:23 PM
Hope you're having fun in your retirement.
So attached is the experiment I tried to see if this is viable. I guess the question really is when the help says they coerce it to the upper or lower is it exactly equal as represented in the computer?
03-22-2012 02:30 PM
I'm stuck at LV 8.2 at this site so can't look at your code.
Interesting question and I would have to experiment to know for sure.
An indicator set for .... 15 decimal places should show all there is to see.
I suspect the value specified for the range is what gets returned.
Clarification:
Not retired yet, but give me an excuse my wife would believe...
Ben
03-22-2012 02:35 PM
Hope this backsaved correctly.
03-22-2012 02:48 PM - edited 03-22-2012 02:50 PM
Why didn't I think of a snippet to begin with?? Never tried it before.
03-22-2012 03:38 PM - edited 03-22-2012 03:40 PM
I think he might be referring to my retirement fund.
When you are using front panel controls the comparison will work because you're a human and you're entering values explicitly, up to a certain precision. The problem occurs when you have calculated floating point values, such as, for example, the output of the Divide function with 1 as the numerator and 3 as the denominator.
I'll stick take that nickel if it's up for grabs.
03-23-2012 03:24 AM
As far as I know, the equal primitive simply compares the bits and since the coercion primitive is officially (assuming I understand the documentation correctly) supposed to coerce to the limit you specify, I would guess this should always work (assuming you're really out of range, of course). The question is what's the point?
03-23-2012 10:14 AM
"(assuming I understand the documentation correctly)" is exactly why I asked the question. The point is if the function shows out of range (false) I can make a single comparison to either the lower or upper limit and determine if the input is lower or higher then the range I specify. I can then act on that information accordingly. I'm basically cascading a couple of these for course and fine tuning to create a kind of 'poor man's proportional control'.
Thanks for everyones attention.
03-24-2012 12:20 PM
Since you already have a couple of operations in your code, you might be better off doing an inequality comparison on both min and max, building the results into a boolean array and using Boolean Array to Number. Then you can feed that into a case structure and process all values in a single place (including NaN).