LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparison Palatte Equal? Not working

Solved!
Go to solution

I have an Equal Comparison as a condition for a while loop. I probed the leads and they are equal however the output is false and the while loop continues to execute. I tried to typecast one wire to the other incase that was a problem(one being a numeric and the other a signed numeric) still not working. Please help?

-Nate
0 Kudos
Message 1 of 11
(5,854 Views)
Solution
Accepted by N8D11

The equal function will work as long as you don't do some silly thing like comparing floating point numbers. If you are, you should do a search for this extremely well discussed subject.

Message 2 of 11
(5,852 Views)

Do you have any screenshots or the VI that you can attach?

 

I have found the equal function to be very specific and even something like an extra space would cause it to not be equal (at least for strings).  Make sure you are sure of what you are comparing.  Is there a different way you could check for comparison?

0 Kudos
Message 3 of 11
(5,842 Views)
0 Kudos
Message 4 of 11
(5,828 Views)

@N8D11 wrote:

I have an Equal Comparison as a condition for a while loop. I probed the leads and they are equal however the output is false and the while loop continues to execute. I tried to typecast one wire to the other incase that was a problem(one being a numeric and the other a signed numeric) still not working. Please help?



I m facing a similar problem using comparison palette Greater than equal to and Equal to. Two same values when compared, the output is false. Please find the example vi attached and help!

0 Kudos
Message 5 of 11
(5,572 Views)

Precision...

 

floatsneq.jpg

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 11
(5,556 Views)

There is no such thing as "Equals" when dealing with floating point numbers.  The best you can do is an "approximately equal" by subtracting the two values and making sure the difference is less than whatever precision you want.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 11
(5,547 Views)

'subtracting the two values' --> don't forget to get the absolute of the difference before you compare to your tolerance limit... 😉

QFang
-------------
CLD LabVIEW 7.1 to 2016
Message 8 of 11
(5,521 Views)

Thank You for your help. The precision and taking its absolute value solved my problem. 🙂 🙂

0 Kudos
Message 9 of 11
(5,483 Views)

@QFang wrote:

'subtracting the two values' --> don't forget to get the absolute of the difference before you compare to your tolerance limit... 😉


Yup here is a made VI that is pretty much this.

 

https://lavag.org/files/file/259-floating-point-almost-equal/

Message 10 of 11
(5,430 Views)