From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
EricC.

Include a binary mode option for the comparaison 'egal' and 'not egal'

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

Because the 'NaN' value is very special, make avaible someting like a binary mode for the test egal and not egal.

So the test 'NaN' not egale to 'NaN' is False.

 

 

binary comparaison.png

Ingénieur d'Application / Développeur LabVIEW Certifié (CLD)
Application Engineer / LabVIEW Certified Developer (CLD)
8 Comments
JackDunaway
Trusted Enthusiast

I was reading up on some SQL the other day, and the author made a clear point that "variable = NULL" by design returns a different result than "variable IS NULL". LabVIEW may have been designed with the same concept - it's impossible to assign comparison equality or inequality to Not a Number. Comments from R&D?

 

Laura, if it is alright with Cthulhu, I would suggest the title of this post be changed to "Include a binary mode option for the comparison 'Equal' and 'Not Equal'" for better searching (it took me a while to realize egal=equal).

tst
Knight of NI Knight of NI
Knight of NI

> it's impossible to assign comparison equality or inequality to Not a Number

 

That's correct. I believe the IEEE standard LV uses specifies that comparing to NaN will always fail.

 

LabVIEW already has a primitive (called Not a Number/Path/Refnum?) which can be used to test if a number is NaN.


___________________
Try to take over the world!
Knight of NI

Cthulhu wrote:

Because the 'NaN' value is very special,


And that's precisely the point. As noted, NaN is not supposed to be used for equality operations. The IEEE standaard that tst alludes to is IEEE754. It states that NaN=NaN always returns false. Further, according to the spec, NaN can actually have a sign, but it has no meaning other than just diagnostics.

altenbach
Knight of NI

Also note that a binary comparison of NaNs can easily fail, because the Mantissa can be arbitrary as long as it is not zero. This means we can have 2^52-1 different NaN and any comparison is meaningless.

 

Here's an illustrative example (from here

EricC.
Active Participant

I know the function "Is NaN/Path/Refnum", but when you have the value 'NaN' in a cluster or in any complex struct, it is not esay to use. So to make a test if the value change, you have only the choice to compare the Flattened to string data.

 

 

Ingénieur d'Application / Développeur LabVIEW Certifié (CLD)
Application Engineer / LabVIEW Certified Developer (CLD)
Knight of NI
Well, even using Flatten To String is not guaranteed to work because NaN is so special. As noted by altenbach, and as detailed in the IEE754 spec I linked to earlier, NaN is only defined by the exponent being a specific pattern. The "fraction" part can be any non-zero value. Thus, a Flatten to String would give you 2^32 - 1 possible flattened values for SGL and 2^52 - 1 possible flattened values for DBL. If you need to do that kind of comparison then you should use Inf or -Inf since the bit pattern for those values is clearly defined.
EricC.
Active Participant

by experience say that the function Flatten To string work well.

When i use this function, i can test a copy of the memory used to record the data.

So i can test if a cluster or an array change betwenn the readed data and his local copy.

Ingénieur d'Application / Développeur LabVIEW Certifié (CLD)
Application Engineer / LabVIEW Certified Developer (CLD)
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.