## ◆ is_negative()

 as_logical_t boost::simd::is_negative ( Value const & x )

This function object returns True if x is negative else False.

This function differs from is_ltz for floating point arguments, because Mzero is negative but not less than zero, and Mzero is not positive and not greater than zero, It's probably is_ltz that you want.

Note

Using is_negative(x) is similar to bitofsign(x) == 1

Example:
#include <boost/simd/predicates.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/inf.hpp>
#include <boost/simd/constant/minf.hpp>
#include <boost/simd/constant/nan.hpp>
#include <boost/simd/constant/mindenormal.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 8>;
int main()
{
pack_ft pf = { 0.0f, 1.0f, -1.0f, -2.0f
, bs::Mindenormal<float>(), bs::Inf<float>(), bs::Minf<float>(), bs::Nan<float>() };
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::is_negative(pf) = " << bs::is_negative(pf) << '\n';
float xf = 1.0f;
float yf = bs::Mindenormal<float>();
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::is_negative(xf) = " << bs::is_negative(xf) << '\n'
<< "<- yf = " << yf << '\n'
<< "-> bs::is_negative(yf) = " << bs::is_negative(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (0, 1, -1, -2, 1.4013e-45, inf, -inf, -nan)
-> bs::is_negative(pf) = (false, false, true, true, false, false, true, true)
---- scalar
<- xf = 1
-> bs::is_negative(xf) = false
<- yf = 1.4013e-45
-> bs::is_negative(yf) = false