maths: use std::signbit instead of builtin
This commit is contained in:
parent
426fc1c848
commit
14cab4fb9b
11
maths.ipp
11
maths.ipp
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user