INF, NAN, and NULL - Exception values
NAN ("not a number"), and
Null are special-valued system constants that Analytica returns in particular conditions, such as exceptions. These constants can also be used as values in expressions.
Infinity or a real number larger than can be represented, e.g.,
An indeterminant number, which is a numeric value that is not well-defined, such as
0/0. The code name NAN suffers from an unfortunate historic misnaming in that it stands for "Not A Number"; however, it is considered to be a numeric data type, and hence
The result of an operation where the desired data is not there, such as
X[I = '?'], where index
Idoes not have the value
INF is the result of a numerical calculation that is mathematically infinite, such as:
1/0 → INF
INF is also the result of a calculation that would produce a number larger than
1.797 x10+308, which is the largest floating point number that Analytica can represent:
10^1000 → INF
INF can be positive or negative:
-1 * 10^1000 → -INF
-1/0 → -Inf
So -INF means negative infinity (or a number below
You can perform useful, mathematically correct arithmetic with INF, such as:
INF + 10 → INF
INF/0 → INF
10 - INF → -INF
100/0 = INF → True
NAN (Not a Number)
NaN is the result of an indeterminate numerical calculation, including numerical functions whose parameter is outside their domain, such as"
INF - INF → NAN
0/0 → NAN
INF/INF → NAN
Sqrt(-1) → NAN
ArcSin(2) → NAN
It usually gives a warning if you apply a function to a parameter value outside its range, such as the two examples above — unless you have checked “Ignore warnings”.
0/0 <> NAN → NAN
Analytica’s representation and treatment of INF and NaN is consistent with ANSI (Association of National Standards Institutes) standards and IEEE Floating point standards. NaN stands for “Not A Number,” which is a bit misleading, since NaN really is a kind of number. You can detect NaN in an expression using the IsNaN() function.
1/INF → 0
1/(-INF) → 0
INF + INF → INF
INF - INF → NAN
True OR NAN → True
NAN AND False → False
IF True THEN 5 ELSE NAN → 5
Nullis a result that is ill-defined, usually indicating that there is nothing at the location requested, for example a subscript using a value that does not match a value of the index:
Index I := 1..5
X[I = 6] → Null
Index Year := [2015, 2016, 2017]
Slice(Year, 4) → NULL
Variable X := Array(Year, [20, 23, 28])
X[Year = 2018] → NULL
You can test for Null using the standard = or <> operators, such as:
X[I = 6] = Null → True
or you can use
IsNull(X[I = 6]). However,
IsNull(x) are different when
x may be an array.
x=Null is a cell-level comparison, where each cell is tested for equality to Null, with the result having the same dimensionality as
IsNull(x) tests whether the entire value is exactly Null. When
x is an array where every cell is equal to Null,
IsNull(x) is false.
10 + Null → Null
Null - 10 → Null
1 AND Null → Null
Array-reducing functions ignore Null. These examples demonstrate (assume
A is indexed by
I as indicated).
variable A :=
I ▶ 1 2 3 4 5 8 Null 4 Null 0
Graphs will simply ignore (not show) any point whose value is Null.
Regression() also ignores any data points which have
Y = Null, which is useful for missing data.