Save as isnan.h:
And then run the following:
And now you can test for Nan, if you decide to.
(There's also isinf which you'd basically implement the same way if you needed it, which tells you if a value is INF or not. If you need it as well, and can't sort it out on your own, I'll happily toss it into a simple header file for you.)
Code: (Select All)
#include <stdio.h>
#include <math.h>
#include <float.h>
int IsNan (long double n);
IsNan (long double n) {
return -isnan(n);
}
Code: (Select All)
DECLARE CUSTOMTYPE LIBRARY "isnan"
FUNCTION IsNan% (n AS DOUBLE)
END DECLARE
PRINT IsNan(1 / 0)
PRINT IsNan(2 / 3)
And now you can test for Nan, if you decide to.
(There's also isinf which you'd basically implement the same way if you needed it, which tells you if a value is INF or not. If you need it as well, and can't sort it out on your own, I'll happily toss it into a simple header file for you.)