...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/math/special_functions/sign.hpp>
namespace boost{ namespace math{ template<class T> int signbit(T x); template <class T> inline int sign (const T& z); template <class T> inline T copysign (const T& x, const T& y); }} // namespaces
template<class T> int signbit(T x);
Returns a non-zero value if the sign bit is set in variable x,
otherwise 0
.
template <class T> inline int sign (const T& z);
Returns 1
if x
> 0
,
-1
if x <
0
, and 0
if x is zero.
template <class T> inline T copysign (const T& x, const T& y);
Sets the sign of x to be the same as the sign of y.