views:

347

answers:

5

Is there a C++ version of the isnormal, isnan and so C functions? I know I can use the C functions from C++, but I'm always interested to know if there are some C++-only alternatives.

A: 

There is no such a functionality in stl. You could check that in reference: cppreference

C functionalities was placed in C++ and APIs are available through headers without postfix "*.h" and with prefix "c" example

<cstdlib>

But I'm certain You know about it.

If You're looking for something simmilar you probably would find many C like functions in amazing boost library. Most of classes would be introduced to new C++ standard so its worth to learn.

boost

bua
Maybe not. You (http://stackoverflow.com/users/147845/you) seems to prefer PHP and Web based questions.
graham.reeds
Wrong window colleague?
bua
A: 

Exact duplicate question

Note: isnan, isnormal and similars are quite easy to redefine as due to IEEE standards there are simple rules (respected in float/double C++ implementation) to check whether a number is "finite" or not. I.E. if "a is nan" then "a is != a".

ZZambia
"Exact duplicate question" : Oops, sorry about that!
static_rtti
C++ implementations are not required to use IEEE floating-point types. They just normally do, because floating point hardware normally provides that, and nobody has come up with anything better.
Steve Jessop
Except if you're using -ffast-math on GCC/G++ (or similar on VC), for 99.9% your compiler is IEEE-754 compliant ;-)
ZZambia
+1  A: 

Boost has some versions of the same.

plinth
A: 

Not as far as I know. Doesn't look like there's one in the STL. Since that's such a simple function I would guess they didn't want to take the time to replace it. The old C version works fine. I would say just continue to use the C isnormal().

Daniel Bingham
+4  A: 

They're included in <cmath> in the C++0x draft:

template <class T> int fpclassify(T x);
template <class T> bool isfinite(T x);
template <class T> bool isinf(T x);
template <class T> bool isnan(T x);
template <class T> bool isnormal(T x);
Stephen Canon