Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with NAN
#10
Save as isnan.h:

Code: (Select All)
#include <stdio.h>
#include <math.h>
#include <float.h>

int IsNan (long double n);
IsNan (long double n) {
    return -isnan(n);
    }
And then run the following:

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


Messages In This Thread
Working with NAN - by Dimster - 09-08-2023, 03:45 PM
RE: Working with NAN - by DSMan195276 - 09-08-2023, 03:57 PM
RE: Working with NAN - by mnrvovrfc - 09-08-2023, 04:03 PM
RE: Working with NAN - by Dimster - 09-08-2023, 06:06 PM
RE: Working with NAN - by mnrvovrfc - 09-08-2023, 06:22 PM
RE: Working with NAN - by DSMan195276 - 09-08-2023, 07:43 PM
RE: Working with NAN - by Dimster - 09-09-2023, 01:42 PM
RE: Working with NAN - by DSMan195276 - 09-09-2023, 02:31 PM
RE: Working with NAN - by Dimster - 09-09-2023, 03:48 PM
RE: Working with NAN - by SMcNeill - 09-09-2023, 05:03 PM
RE: Working with NAN - by Dimster - 09-09-2023, 06:48 PM
RE: Working with NAN - by SMcNeill - 09-09-2023, 07:11 PM
RE: Working with NAN - by SMcNeill - 09-09-2023, 07:26 PM
RE: Working with NAN - by SMcNeill - 09-09-2023, 08:15 PM
RE: Working with NAN - by grymmjack - 09-10-2023, 12:24 AM
RE: Working with NAN - by eoredson - 09-15-2023, 03:03 AM



Users browsing this thread: 11 Guest(s)