LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I check if the result is NaN

If you are afraid that a user input may cause a NaN. You can right click on a control and select "Data Entry" In this menu you can define a valid range 


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 11 of 15
(1,077 Views)
Thank you, Altenbach.
0 Kudos
Message 12 of 15
(1,077 Views)

This is how:

// The equivalent of:
// if( isnan( f ) ) {;} 
// is:
if( !( f == f )) {;}

If the variable is not nan the equality operator will always output true when the same variable is compared with itself. But because the result of any comparison operation done with a nan is always false, if that variable is a nan the result will always be false.

 

0 Kudos
Message 13 of 15
(574 Views)

Artst wrote:
// The equivalent of:
// if( isnan( f ) ) {;} 
// is:
if( !( f == f )) {;}

 


Why would you post offtopic text code in a LabVIEW forum? (and in a thread that is 8+ years old!)

 


@Artst wrote:

... because the result of any comparison operation done with a nan is always false, ....


This statement is incorrect too. Some comparisons with NaN result in a TRUE. Here is one of them.

 

NanCom.png

0 Kudos
Message 14 of 15
(555 Views)

Hi!

There is a discussion about the same problem for MATLAB. As I understand it, acording to IEEE 754 standard +Inf, -Inf and NaN are valid results for math processors. If the "division-by-zero test" is built into LabView software it would slow the performance. So: there is no general solution to check our floating point operations. If necessary we will have to do it on a case-by-case basis.

0 Kudos
Message 15 of 15
(540 Views)