## ◆ exponent()

 as_integer_t boost::simd::exponent ( Value const & x )

This function object returns the exponent of the floating input.

Note:

The exponent $$e$$ and mantissa $$m$$ of a floating point entry $$x$$ are related by $$x = m\times 2^e$$, with $$|m| \in [1, 2[$$ (except for $$x = 0$$, where $$m=0$$ and $$e=0$$ ).

For integral type inputs exponent is always 0 and mantissa reduces to identity.

mantissa, frexp, ldexp
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::exponent(pf) = " << bs::exponent(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::exponent(xf) = " << bs::exponent(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::exponent(pf) = (0, 1, 0, -1)
---- scalar
<- xf = 2
-> bs::exponent(xf) = 1