## ◆ signnz()

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

This function object returns the sign of x.

I.e. -1 or 1, depending on the fact x is negative or positive.

Notes:
• This function never returns Zero (zero is considered positive for integers).
• For floating point numbers the bit of sign is taken into account and so we always have signnz(-z) == -signnz(z) except is the entry is a NaN (in this later case the result is undefined).
Mzero, sign, is_negative, is_positive
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::signnz(pf) = " << bs::signnz(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::signnz(xf) = " << bs::signnz(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::signnz(pf) = (1, 1, -1, 1)
---- scalar
<- xf = 2
-> bs::signnz(xf) = 1