## ◆ ilogb()

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

This function object Extracts the value of the unbiased exponent from the floating-point argument x, and returns it as a signed integer value.

Note:
• Formally, the unbiased exponent is the integral part of $$\log_r|x|$$ as a signed integral value, for non-zero x, where r is std::numeric_limits<T>::radix and T is the floating-point type of arg.
• In practice r = 2 for all supported platforms
• boost::simd::ilogb differ from std::ilogb in the return type that is always the integer type associated to the input type and the limiting values (zero return zero and the result is always greater than zero)
• for floating inputs nan and zero returns zero and +-inf return Valmax
Decorators
• pedantic_ return FP_ILOGB0 and FP_ILOGBNAN for 0 and nan respectively, but the return type is as in the regular call.
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::ilogb(pf) = " << bs::ilogb(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::ilogb(xf) = " << bs::ilogb(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::ilogb(pf) = (0, 1, 0, -1)
---- scalar
<- xf = 2
-> bs::ilogb(xf) = 1