`isnan`

, `_isnan`

, `_isnanf`

Tests if a floating-point value is a NaN ("Not a Number").

## Syntax

```
int isnan(
/* floating-point */ x
); /* C-only macro */
int _isnan(
double x
);
int _isnanf(
float x
); /* x64 only */
template <class T>
bool isnan(
T x
) throw(); /* C++ only */
```

### Parameters

`x`

The floating-point value to test.

## Return value

In C, the ** isnan** macro and the

**and**

`_isnan`

**functions return a non-zero value if the argument**

`_isnanf`

*is a NaN; otherwise they return 0.*

`x`

In C++, the ** isnan** template function returns

**if the argument**

`true`

*is a NaN; otherwise it returns*

`x`

**.**

`false`

## Remarks

Because a NaN value doesn't compare as equal to itself or to any other NaN value, to detect one, you must use one of these functions or macros. A NaN is generated when the result of a floating-point operation can't be represented in IEEE-754 floating-point format for the specified type. For information about how a NaN is represented for output, see `printf`

.

When compiled as C++, the ** isnan** macro isn't defined, and an

**template function is defined instead. It behaves the same way as the macro, but returns a value of type**

`isnan`

**instead of an integer.**

`bool`

The ** _isnan** and

**functions are Microsoft-specific. The**

`_isnanf`

**function is only available when compiled for x64.**

`_isnanf`

## Requirements

Routine | Required header (C) | Required header (C++) |
---|---|---|

, `isnan` `_isnanf` |
<math.h> | <math.h> or <cmath> |

`_isnan` |
<float.h> | <float.h> or <cfloat> |

For more compatibility information, see Compatibility.

## See also

Math and floating-point support

`fpclassify`

`_fpclass`

, `_fpclassf`

`isfinite`

, `_finite`

, `_finitef`

`isinf`

`isnormal`

## Feedback

Submit and view feedback for