LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Equal comparison on DBL post in range and coerce?

Solved!
Go to solution

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. Smiley Wink

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 1 of 11
(2,784 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 11
(2,780 Views)

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?

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 3 of 11
(2,776 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 11
(2,772 Views)

Hope this backsaved correctly.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 5 of 11
(2,764 Views)

Why didn't I think of a snippet to begin with?? Never tried it before.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 6 of 11
(2,759 Views)

I think he might be referring to my retirement fund. Smiley Wink

 

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.Smiley Very Happy

Message 7 of 11
(2,752 Views)
Solution
Accepted by topic author GovBob

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?


___________________
Try to take over the world!
0 Kudos
Message 8 of 11
(2,723 Views)

"(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.

 

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 9 of 11
(2,705 Views)

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).


___________________
Try to take over the world!
Message 10 of 11
(2,682 Views)