LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Clusters with NaN elements

Solved!
Go to solution

@paul_a_cardinale wrote:

This works for any cluster:

paul_a_cardinale_0-1727780373063.png

Once a NaN is packaged in a variant, the rules about comparing NaNs are no longer applied; all NaNs are considered equal.

However this could be construed as a bug, and may be 'fixed' in the future.


I gotta see that more closely.   Could you please elaborate!  (Don't make me actually boot up the laptop - I honestly haven't even opened LabVIEW for over a year)


"Should be" isn't "Is" -Jay
0 Kudos
Message 21 of 26
(202 Views)

@softball wrote:

Hi Paul

 

You are right, and you are wrong.

 

softball_1-1727786568332.png

 

'To Variant' works like 'Flatten To String'. It converts a NaN to a representation that can be compared directly.

 

However, if the NaN's involved are binary different as shown in the case above then a NaN comparison will still fail.

 

But interesting. Maybe a 'To Variant' is faster than 'Flatten To String'.

 

Regards


What's the bottom ÷ for? The output is not wired.


"Should be" isn't "Is" -Jay
0 Kudos
Message 22 of 26
(199 Views)

Hi

 

Sorry for confusing you. Just ignore the ÷. It isn't connected to anything as you noted. Just me being lazy when generating the example.

 

Regards

0 Kudos
Message 23 of 26
(192 Views)
Solution
Accepted by littlesphaeroid

@softball wrote:

Hi Paul

 

You are right, and you are wrong.

 

softball_1-1727786568332.png

 

'To Variant' works like 'Flatten To String'. It converts a NaN to a representation that can be compared directly.

 

However, if the NaN's involved are binary different as shown in the case above then a NaN comparison will still fail.

 

But interesting. Maybe a 'To Variant' is faster than 'Flatten To String'.

 

Regards


Good catch.

Flatten to XML works with any NaN.

paul_a_cardinale_0-1727792872942.png

 

Message 24 of 26
(173 Views)
Solution
Accepted by littlesphaeroid

Hi Paul

 

Brilliant !

 

Different NaN values get converted to a generic 'NaN' string. Just like we want it.

 

softball_3-1727796746747.png

 

Regards

 

PS : This behavior would be a nice candidate for a LabVIEW ini setting.

PPS : Except it would encourage some to compare floating point values for equal or not. Which is a bad idea.

Message 25 of 26
(154 Views)

This has been a very interesting conversation. Before reading the last few entries I also tried the flatten to string comparison, and for my purpose it works, since I'm comparing two versions of the same (complex) cluster, and whose NaN values haae the same origin. It does sound like flattening to XML is even more reliable.

 

 

 

NaN compare.png

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 26 of 26
(133 Views)