INF, NAN, and NULL - Exception values
INF ("infinity"), 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.
| Constant | Meaning |
|---|---|
INF
|
Infinity or a real number larger than can be represented, e.g., 1/0
|
NAN
|
Not a Number: Actually, the result is known to be “number” but not well
defined, e.g., |
Null
|
The result of an operation where the desired data is not there, such as
|
INF
INF (infinity): INF is the result of a numerical calculation whose absolute value is larger than largest number Analytica can represent. This could be an overflow — that is a valid real number greater than 1.797 x10+308:
10^1000 → INF
or it could be a division by zero or other result that is mathematically infinite:
1/0 → INF
INF can be positive or negative:
-1 * 10^1000 → -INF-1/0 → -Inf
Using INF as a value in an expression, you can perform useful, mathematically correct arithmetic with INF, such as:
INF + 10 → INFINF/0 → INF10 - INF → -INF100/0 = INF → True
NAN
NAN: NAN is the result of a numerical calculation that is an undetermined or imaginary number, including numerical functions whose parameter is outside their domain:
INF - INF → NAN0/0 → NANINF/INF → NANSqrt(-1) → NANArcSin(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 pressed “Ignore warnings”.
Any arithmetic operation, comparison, or function applied to NAN returns NAN:
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.
Calculations performed with INF and NAN follow the laws of mathematics:
1/Inf → 01/(-Inf) → 0Inf + Inf → InfInf - Inf → NAN
Expressions taking NAN as an operand or parameter give NAN as their result unless the expression has a well-defined logical or numerical value for any value of NAN:
True OR NAN → TrueNaN AND False → FalseIF True THEN 5 ELSE NAN → 5
NULL
Null: 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..5X[I=6] → Null
Other operations and functions that can return Null include Slice(), Subscript(), Subindex(), and MDTable().
You can test for Null using the standard = or <> operators, such as:
X[I=6] = Null → True
or you can use IsUndef(X[I=6]).
When NULL appears in scalar operations, it generally produces a warning and evaluates to NULL, for example:
10 + NULL → NULLNULL - 10 → NULL1 AND NULL → NULL
Array-reducing functions ignore NULL. These examples demonstrate (assume A is indexed by I as indicated).
I: 1 2 3 4 5 A: 8 NULL 4 NULL 0
Graphs will simply ignore (not show) any point whose value is NULL.
Array-reducing functions include Sum, Min, Max, ArgMin, ArgMax, Product, Average, JoinText, Irr, Npv. Array functions Sum, Min and Max also accept an optional parameter IgnoreNaN to ignore NaN values (which otherwise propagate, i.e. return NaN).
Regression also ignores any data points which have Y=Null, which is useful for missing data.
Enable comment auto-refresher