Data Type Functions
Analytica provides several functions for checking the data type of atoms (i.e., the items in an array). These are found in the Special library.
IsNaN(X : Atomic)
NaN is a special value arising from indeterminate arithmetic operations indicating "Not A Number". NaN can arise from operations such as:
0 / 0 0 * INF INF - INF IgnoreWarnings(Ln(-1)) IgnoreWarnings(Sqrt(-1))
The last two cases result in NaN since Analytica does not have internal support for complex numbers. The other cases result because the result is indeterminate.
IsNaN(X) returns 1 (i.e., true) when X is the special value NaN, 0 (false) otherwise.
IsNumber( X : Atomic )
Returns true when X is a number, or any of the special values INF, -INF, or NaN.
IsReference( X : Atomic )
Returns 1 (true) when X is a reference, 0 otherwise. When X is a reference, you can use the #X operator.
IsText( X : Atomic )
Returns 1 (true) when X is a textual string, 0 otherwise.
Comparison to Null
The expressions X=Null or X<>Null can be used to test whether X is the special system constant Null. Null results from certain operations where the value is not found, such as A[I=X] when X is not an element of I (and warnings are ignored).
Null can also be detected using IsUndef(X).
IsUndef(X : Atomic )
Returns True if X is either of the two special system constants Undefined or Null. Undefined is a special system constant indicating that an attribute does not yet have a value, and also used to indicate that a value is not yet computed (e.g., that the (mid) value or probValue attribute do not yet have a value), or that an optional parameter to a function was not specified. Null is a value returned by function evaluations indicating that a requested value is out-of-range or does not exist.
The special value Null was introduced into Analytica 3.0. Prior to that, many functions returned Undefined when values did not exist, but were changed to return Null. To handle backward compatibility where the IsUndef function was being used to test for these values, IsUndef returns true in both cases.
TypeOf( X : Atomic ; Shallow : optional boolean )
(New to Analytica 4.0)
Returns the name of the atomic data type of X as a textual string. When TypeOf is applied to an array, the result is an array, where each cell contains the data type of the corresponding item in the original array.
The common return values for TypeOf(X) are the following:
- "Number" - whenever IsNumber(X)
- "Text" - whenever IsText(X)
- "Null" - whenever X = Null
- "Undefined" - whenever IsUndef(X) and X<>Null
- "Reference" - whenever IsReference(X)
Enable comment auto-refresher