nan and inf detection c++

Started by
1 comment, last by Yann L 16 years, 1 month ago
Hi all: How can I detect if a value is nan or inf please? For example

float x;
...
if (x == nan || x == inf || x == -inf){
...
}

Can I do something like this please? Thanks
Asura
Advertisement
Check the functions in the cmath header. Specifically, isnan and isinf.
if( x != x ) {  // it's a nan}


This topic is closed to new replies.

Advertisement