Skip to content

Commit 8785d8d

Browse files
serge-sans-pailleJohanMabille
authored andcommitted
Fix scalar version of signbit
It returns invalid value for nan. std::signbit appears to be missing on some Windows target for integral types.
1 parent 59c407d commit 8785d8d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/xsimd/arch/xsimd_scalar.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,21 @@ namespace xsimd
825825
return T(x < T(0));
826826
}
827827

828+
XSIMD_INLINE float bitofsign(float const& x) noexcept
829+
{
830+
return float(std::signbit(x));
831+
}
832+
833+
XSIMD_INLINE double bitofsign(double const& x) noexcept
834+
{
835+
return double(std::signbit(x));
836+
}
837+
838+
XSIMD_INLINE long double bitofsign(long double const& x) noexcept
839+
{
840+
return static_cast<long double>(std::signbit(x));
841+
}
842+
828843
template <class T>
829844
XSIMD_INLINE auto signbit(T const& v) noexcept -> decltype(bitofsign(v))
830845
{

0 commit comments

Comments
 (0)