Hi
For the purposes of debugging a program, I would like to be able to ask whether a (double) variable has the value NAN (not a number). My question how do I check if x == NAN ?
For example:
#include <stdio.h>
#include <math.h>
int main()
{
double x;
[blue]x = sqrt(-1.0);[/blue]
printf("x = %f\n", x); /*prints "x = nan"*/
[red]if (x == NAN)[/red]
[blue]/*compiler doesn't know NAN or nan*/[/blue]
printf("x = NAN\n");
return 0;
}
Thanks
zub
For the purposes of debugging a program, I would like to be able to ask whether a (double) variable has the value NAN (not a number). My question how do I check if x == NAN ?
For example:
#include <stdio.h>
#include <math.h>
int main()
{
double x;
[blue]x = sqrt(-1.0);[/blue]
printf("x = %f\n", x); /*prints "x = nan"*/
[red]if (x == NAN)[/red]
[blue]/*compiler doesn't know NAN or nan*/[/blue]
printf("x = NAN\n");
return 0;
}
Thanks
zub