Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use NAN 1

Status
Not open for further replies.

zub44

Programmer
Dec 18, 2003
7
0
0
US
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
 
Code:
       #include <math.h>
       int isnan(double value);


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top