is_nan

Description

Check if x is a valid floating point number.

Invalid floating point numbers are refered to as NaNs (Not a Number). A NaN is generated when an attempt is made to calculate an invalid result (e.g. the square root of a negative number or division by 0). A NaN is also generated if overflow or underflow occures during a calculation, that is, if the result is too big or to small to hold in a floating point variable.

A calculation performed with one or more NaNs will itself yield a NaN. This means that once an error occures within a calculation it will propergate to the final result without the need to check each stage individually.

e.g.

x = 1
y = 0

z = (x / y) + 2 * ((x + 1) / (y - 1))
will result in a NaN

Definition

ubyte is_nan(float x)

Library

LIB/math_lib.bas

Usage

On entry:
x is the value to be checked
On exit:
Return false if x is a valid floating point number and return true if x is NOT a valid floating point number.