2

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.

static_rtti
  • 53,760
  • 47
  • 136
  • 192

3 Answers3

5

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
  • 103,815
  • 19
  • 183
  • 269
2

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
  • 4,761
  • 1
  • 26
  • 32
1

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
  • 12,414
  • 18
  • 67
  • 93