On this page
isnan
Prev: floor | Up: math.h | Next: time.h
Rel: math.h, math, time & assert Guide
Ref: cppreference — isnan
Tags: #public #prog #c #stdlib #math #tier/core
Include
#include <math.h>
Signature & Overview
bool isnan(floating x); /* also isinf, isfinite */
Type-generic macro returning non-zero if x is NaN (x == x is always false for NaN).
Notes & Pitfalls
- Never test
x == NAN(always false!): Always useisnan(x)orisfinite(x).
Example
#include <assert.h>
#include <math.h>
int main(void) {
double x = NAN;
assert(isnan(x) && !(x == x));
}
Linked from
Related notes
- tuts/c/stdlib/math/floor Linked here; links to this page; shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math Linked here; links to this page; shared tags: #c, #math, #prog, #stdlib
- tuts/c/stdlib/math_time_and_assert Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/time Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math/pow shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math/sqrt shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isalpha shared tags: #c, #prog, #stdlib, #tier