## ◆ is_even()

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

This function object returns True or False according x is even or not.

Note:

The call to is_even(x) is similar to to_int(x/2)*2 == x

A floating number is even if it is a flint and divided by two it is still a flint.

A flint is a 'floating integer' i.e. a floating number representing an integer value

Be conscious that all sufficiently great floating points values are even...

is_odd, is_flint
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, 4>;
int main()
{
pack_ft pf = { 0.0f, 1.0f, -1.0f, -2.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::is_even(pf) = " << bs::is_even(pf) << '\n';
float xf = 1.0f;
float yf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::is_even(xf) = " << bs::is_even(xf) << '\n'
<< "<- yf = " << yf << '\n'
<< "-> bs::is_even(yf) = " << bs::is_even(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (0, 1, -1, -2)
-> bs::is_even(pf) = (true, false, false, true)
---- scalar
<- xf = 1
-> bs::is_even(xf) = false
<- yf = 2
-> bs::is_even(yf) = true