macro/function
<cmath> <ctgmath>
isnan functionbool isnan (float x);bool isnan (double x);bool isnan (long double x);
Is Not-A-Number
Returns whether x is a NaN (Not-A-Number) value.The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
In C, this is implemented as a macro that returns an int
value. The type of x shall be float
, double
or long double
.
In C++, it is implemented with function overloads for each
floating-point type, each returning a
bool
value.
true
) if x is a NaN value; and zero (false
) otherwise.
1
2
3
4
5
6
7
8
9
10
11
12
/* isnan example */
#include <stdio.h> /* printf */
#include <math.h> /* isnan, sqrt */
int main()
{
printf ("isnan(0.0) : %d\n",isnan(0.0));
printf ("isnan(1.0/0.0) : %d\n",isnan(1.0/0.0));
printf ("isnan(-1.0/0.0) : %d\n",isnan(-1.0/0.0));
printf ("isnan(sqrt(-1.0)): %d\n",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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4