In a CR1000-code we do a comparison of a temperature sensors value, to check if it's in a normal range or the sensor should be set in a error state.
If (Thermistor_value > THERM_ERR_MAX OR Thermistor_value < THERM_ERR_MIN) Then
But as the value is a NAN, the result of the IF seems to be false and therefore the sensor is not set to error state as it's supposed to.
So my question, what is the result of for example, the following expression:
NAN > 100 OR NAN < -50
Would my problem be solved if I change the logic to:
NAN < -50 AND NAN > 100
Thanks a lot for your help. Best regards, Chasper
I think the conditional statement that you want is this:
If (Thermistor_value > THERM_ERR_MAX) OR (Thermistor_value < THERM_ERR_MIN)
OR (Thermistor_value = NAN ) Then
Thank's a lot for your answer. Yes, your suggestion will surrely work.
It's only that I was interested how a NAN is handled. Actually I changed the logic of the question and changed the true and the else code so it works as well.
Thanks you very much and good evening. Best regards, Chasper
In most languages thsat support floating point math, particularly those that use the IEEE-754 specification, NAN is defined as a collection of bit patterns that are not comparable even with themselves. CRBasic overloads the equality comparison operator to test if both operands are NaN. It makes no sense, however, to perform inequality comparisons with NaN since, by its definition, the value is not a number.
I was actually fighting this in an Excel spreadsheet this week. Error values such as NAN must be checked for specifically. (in Excel I had to use IFERROR) As shown before, you need to specifically check if the value equals NAN.
Is grey taller than an elephant? False (a color doesn't have height)
Is the elephant grey? True
NAN is neither greater than 100 nor less than -50. The comparison can't be true, because NAN is not a number. A variable may be equal to NAN, so you can check for that.