Understanding NAN and INF occurrences

ClosedNAN Not a number. A data word indicating a measurement or processing error. Voltage overrange, SDI-12 sensor error, and undefined mathematical results can produce NAN. (not a number) and ClosedINF A data word indicating the result of a function is infinite or undefined. (infinite) are data words indicating an exceptional occurrence in data logger function or processing. INF indicates that the program has encountered an undefined arithmetic expression, such as 0 ÷ 0. NAN indicates an invalid measurement. For more information, see Tips and Tricks: Who's NAN? .

NANs are expected in the following conditions:

  • Input signals exceed the voltage range chosen for the measurement.
  • An invalid SDI-12 command is sent.
  • An SDI-12 sensor does not respond or aborts without sending data.

NAN is a constant that can be used in expressions. This is shown in the following example code that sets a ClosedCRBasic Campbell Scientific's BASIC-like programming language that supports analog and digital measurements, data processing and analysis routines, hardware control, and many communications protocols. variable to False when the wind direction is NAN:

If WindDir = NAN Then
   WDFlag = False
Else
   WDFlag = True
EndIf

If an output processing instruction encounters a NAN in the values being processed, NAN will be stored. For example, if one measurement in a data storage interval results in NAN, then the average, maximum and minimum will record NAN. However, because NAN is a constant, it can be used in conjunction with the disable variable parameter (DisableVar) in output processing instructions. Use variable = NAN in the DisableVar parameter to discard NANs from affecting the other good values. The following example code discards NAN WindSpeed measurements from the Minimum output:

Minimum (1,WindSpeed,FP2,WindSpeed=NAN,False)

NOTE:

There is no such thing as NAN for integers. Values that are converted from float to integer will be expressed in data tables as the most negative number for a given data type. For example, the most negative number of data type FP2 is –7999; so, NAN for FP2 data will appear in a data table as –7999. If the data type is Long, NAN will appear in the data table as –2147483648.