◆ frac()

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

This function object returns the fractional part of the input i.e.

x-trunc(x).

See also
trunc, modf
Header <boost/simd/function/frac.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::frac(pf) = " << bs::frac(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::frac(xf) = " << bs::frac(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::frac(pf) = (0, 0, 0, 0.5)
---- scalar
<- xf = 2
-> bs::frac(xf) = 0