# NAN

> C++ Atlas: `cppatlas.com/w/cpp/numeric/math/NAN` | Source: https://en.cppreference.com/w/cpp/numeric/math/NAN | Domain: Numerics | Standards: C++11

The macro NAN expands to constant expression of type float which evaluates to a quiet not-a-number (QNaN) value. If the implementation does not support QNaNs, this macro constant is not defined.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <cmath>
#define NAN /*implementation defined*/ // (since C++11)
```

The macro `NAN` expands to constant expression of type `float` which evaluates to a quiet not-a-number (QNaN) value. If the implementation does not support QNaNs, this macro constant is not defined.

### Notes

There are many different NaN values, differentiated by their payloads and their sign bits. The contents of the payload and the sign bit of the NaN generated by the macro `NAN` are implementation-defined.

### See also

- [`nan`](https://en.cppreference.com/w/cpp/numeric/math/nan) (C++11), [`nanf`](https://en.cppreference.com/w/cpp/numeric/math/nan) (C++11), [`nanl`](https://en.cppreference.com/w/cpp/numeric/math/nan) (C++11): not-a-number (NaN) (function)
- [`isnan`](https://en.cppreference.com/w/cpp/numeric/math/isnan) (C++11): checks if the given number is NaN (function)
- [`has_quiet_NaN`](https://en.cppreference.com/w/cpp/types/numeric_limits/has_quiet_NaN) [static]: identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) (public static member constant of `std::numeric_limits<T>`)
- [`has_signaling_NaN`](https://en.cppreference.com/w/cpp/types/numeric_limits/has_signaling_NaN) [static]: identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) (public static member constant of `std::numeric_limits<T>`)
- [`quiet_NaN`](https://en.cppreference.com/w/cpp/types/numeric_limits/quiet_NaN) [static]: returns a quiet NaN value of the given floating-point type (public static member function of `std::numeric_limits<T>`)
- [`signaling_NaN`](https://en.cppreference.com/w/cpp/types/numeric_limits/signaling_NaN) [static]: returns a signaling NaN value of the given floating-point type (public static member function of `std::numeric_limits<T>`)
- [C documentation for `NAN`](https://en.cppreference.com/w/c/numeric/math/NAN)

---
Attribution: content from https://en.cppreference.com/w/cpp/numeric/math/NAN (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.