Skip to content

Commit

Permalink
Fix scalar version of signbit
Browse files Browse the repository at this point in the history
It returns invalid value for nan.

std::signbit appears to be missing on some Windows target for integral
types.
  • Loading branch information
serge-sans-paille committed Apr 30, 2024
1 parent 59c407d commit 29e07fb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/xsimd/arch/xsimd_scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,21 @@ namespace xsimd
return T(x < T(0));
}

XSIMD_INLINE float bitofsign(float const& x) noexcept
{
return float(std::signbit(x));
}

XSIMD_INLINE double bitofsign(double const& x) noexcept
{
return double(std::signbit(x));
}

XSIMD_INLINE long double bitofsign(long double const& x) noexcept
{
return static_cast<long double>(std::signbit(x));
}

template <class T>
XSIMD_INLINE auto signbit(T const& v) noexcept -> decltype(bitofsign(v))
{
Expand Down

0 comments on commit 29e07fb

Please sign in to comment.