◆ bitofsign()

Value boost::simd::bitofsign ( Value const &  x)

This function object returns a value of the same type as the input with all bits set to zero except the sign bit which is preserved.

This function object returns always Zero for unsigned types

Header <boost/simd/function/bitofsign.hpp>
Example:
#include <boost/simd/ieee.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::bitofsign(pf) = " << bs::bitofsign(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::bitofsign(xf) = " << bs::bitofsign(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::bitofsign(pf) = (0, 0, -0, 0)
---- scalar
<- xf = 2
-> bs::bitofsign(xf) = 0