maths: use std::signbit instead of builtin

This commit is contained in:
Danny Robson 2015-04-07 16:53:11 +10:00
parent 426fc1c848
commit 14cab4fb9b

View File

@ -48,25 +48,26 @@ pow (T x, unsigned y)
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
/// Return a unit type with a sign that matches the provided value /// Return a unit type with a sign that matches the provided value
/// ///
/// This really needs to be inline for performance as it's used in a few inner /// We were using __builtin_signbit for the potential speedboost, but it causes
/// loops where the possibility of a function call is a deal breaker. /// problems with constexpr under clang. If you need speed then you'll probably
/// have to handcode something.
constexpr int constexpr int
sign (int v) sign (int v)
{ {
return __builtin_signbitl (v) ? -1 : 1; return std::signbit (v) ? -1 : 1;
} }
constexpr float constexpr float
sign (float v) sign (float v)
{ {
return __builtin_signbitf (v) ? -1.f : 1.f; return std::signbit (v) ? -1.f : 1.f;
} }
constexpr double constexpr double
sign (double v) sign (double v)
{ {
return __builtin_signbit (v) ? -1. : 1.f; return std::signbit (v) ? -1. : 1.f;
} }