Check For Nan Value


EOlsen

Recommended Posts

I have a variable I'm using to store a color value. It gets set to NaN at one point in my code which isn't a problem. The problem is I want to check to see if it is set to NaN and if so change it to some other value.

 

The variable isn't empty. So IsEmpty(myvar) returns 0. Trying to compare myvar == NaN() generates a C1066 Invalid operator error.

 

global myvar = NaN()

? myvar // Shows NaN

 

if (myvar == NaN()) // Generates error code

 

 

How can I check to see if the variable is equal to NaN and then change it to something else?

Link to comment
Share on other sites

You must have some other typo.  I plug this into a sequence:

 

global myvar = nan()
? myvar
if (myvar == NaN())
   ? "is nan"
else
   ? "is real"
endif
 
and "NaN" followed by "is nan" is printed.  No errors.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.