Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

cmath

Header <boost/core/cmath.hpp>

Authors

  • Peter Dimov

The header <boost/core/cmath.hpp> defines, in a portable way, the floating point classification and sign manipulation functions from C++11.

namespace boost
{
namespace core
{

// fpclassify return values

int const fp_zero = /*unspecified*/;
int const fp_subnormal = /*unspecified*/;
int const fp_normal = /*unspecified*/;
int const fp_infinite = /*unspecified*/;
int const fp_nan = /*unspecified*/;

// Classification functions

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

// Sign manipulation functions

template<class T> bool signbit( T x );
template<class T> T copysign( T x, T y );

} // namespace core
} // namespace boost
  • Requires: T must be float, double, or long double.
  • Returns: true when x is finite (not infinity or NaN), false otherwise.
  • Requires: T must be float, double, or long double.
  • Returns: true when x is NaN, false otherwise.
  • Requires: T must be float, double, or long double.
  • Returns: true when x is infinity, false otherwise.
  • Requires: T must be float, double, or long double.
  • Returns: true when x is a normal number (not zero, subnormal, infinity, or NaN), false otherwise.
  • Requires: T must be float, double, or long double.
  • Returns:
    • fp_zero when x is zero;
    • fp_subnormal when x is subnormal;
    • fp_infinite when x is infinity;
    • fp_nan when x is NaN;
    • fp_normal otherwise.
  • Requires: T must be float, double, or long double.
  • Returns: true when x is negative, false otherwise.
  • Requires: T must be float, double, or long double.
  • Returns: x with the sign copied from y.

PrevUpHomeNext