# Difference between revisions of "INF, NAN, and Null"

m (→More on NULL) |
m (→More on INF and NAN) |
||

Line 26: | Line 26: | ||

:Inf + Inf → Inf | :Inf + Inf → Inf | ||

:Inf - Inf → NAN | :Inf - Inf → NAN | ||

+ | |||

+ | NAN in operand does not always generate NAN as the result if the expression has a well-defined logical or numerical value no matter what the value of NAN: | ||

+ | |||

+ | :True OR NAN → True | ||

+ | :NaN AND False → False | ||

+ | :IF True THEN 5 ELSE NAN → 5 | ||

=== More on NULL === | === More on NULL === |

## Revision as of 18:53, 28 January 2015

These are special values that Analytica returns in particular conditions. You can also use them in expressions:

**Inf** means infinity -- e.g.,

- 1/0 → Inf

or a number larger than 1.796E308 (due to computer limitations) -- e.g.

- 1E307 * 100 → Inf

**-Inf** means negative infinity -- e.g.,

- -1/0 → -Inf

or a number less than 1.796E308

**NAN** means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g.

- 0/0 → NAN
- Sqrt(-1) → NAN

except if you enable Complex Numbers, in which case this will return a valid imaginary number, 1j.

**Null** means that there is no such value. For example, Slice and Subscript return Null if you try to get the nth slice over an Index with less than n values.

### More on INF and NAN

Analytica follows ANSI (Association of National Standards Institutes) standards for computing with these special values, where applicable.

- 1/Inf → 0
- 1/(-Inf) → 0
- Inf + Inf → Inf
- Inf - Inf → NAN

NAN in operand does not always generate NAN as the result if the expression has a well-defined logical or numerical value no matter what the value of NAN:

- True OR NAN → True
- NaN AND False → False
- IF True THEN 5 ELSE NAN → 5

### More on NULL

When NULL appears in scalar operations, it generally produces a warning and evaluates to NULL, for example:

- 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).

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