## ◆ ifrexp()

 std::pair > boost::simd::ifrexp ( IEEEValue const & x )

This function object computes a mantissa and an exponent pair for the input.

Semantic:

For every parameter of floating type T

std::tie(m, e)= ifrexp(x);

is similar to:

as_integer_t<T> e = exponent(x)+1;
T m = mantissa(x)/2;
Note:

if you need floating type exponent (unlike the standard) use frexp

This function splits a floating point value $$x$$ in a signed mantissa $$m$$ and an exponent $$e$$ so that: $$x = m\times 2^e$$, with absolute value of $$m \in [0.5, 1[$$ (except for $$x = 0$$)

Without the pedantic_ decorator Nan or Inf are not handled properly.

Warning
Take care that these results differ from the returns of the functions mantissa and exponent
Decorators
• pedantic_ slower, but special values as Nan or Inf are handled properly.
• std_ transmits the call to std::frexp.
exponent, mantissa, frexp
Example:
#include <boost/simd/ieee.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
using pack_it = bs::pack <int32_t, 4>;
int main()
{
pack_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
pack_ft pm;
pack_it pie;
std::tie(pm, pie) = bs::ifrexp(pf);
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> std::tie(pm, pie) = bs::ifrexp(pf) = " << '\n'
<< "-> pm = " << pm << '\n'
<< "-> pie = " << pie<< '\n' ;
float xf = 2.0f;
float m;
std::int32_t ie;
std::tie(m, ie) = bs::ifrexp(xf);
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< "-> std::tie(m, ie) = bs::ifrexp(xf) = " << '\n'
<< "-> m = " << m << '\n'
<< "-> ie = " << ie << '\n' ;
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> std::tie(pm, pie) = bs::ifrexp(pf) =
-> pm = (0.5, 0.5, -0.5, 0.5)
-> pie = (1, 2, 1, 0)
---- scalar
xf = 2
-> std::tie(m, ie) = bs::ifrexp(xf) =
-> m = 0.5
-> ie = 2