/* isnan example */ #include <stdio.h> /* printf */ #include <math.h> /* isnan, sqrt */ int main() { printf ("isnan(0.0) : %d ",isnan(0.0)); printf ("isnan(1.0/0.0) : %d ",isnan(1.0/0.0)); printf ("isnan(-1.0/0.0) : %d ",isnan(-1.0/0.0)); printf ("isnan(sqrt(-1.0)): %d ",isnan(sqrt(-1.0))); return 0; }
输出
isnan(0.0) : 0 isnan(1.0/0.0) : 0 isnan(-1.0/0.0) : 0 isnan(sqrt(-1.0)): -1