◆ fpclassify()

as_integer_t<IEEEValue> boost::simd::fpclassify ( IEEEValue const &  x)

This function object categorizes floating point value into the following categories: zero, subnormal, normal, infinite, nan, or implementation-defined.

Header <boost/simd/function/fpclassify.hpp>
Notes
  • fpclassify returns a value of integral type that matches one of the classification macro constants, depending on the value of x : value description:

    • FP_INFINITE Positive or negative infinity
    • FP_NAN Not-A-Number
    • FP_ZERO Value of zero
    • FP_SUBNORMAL Sub-normal value
    • FP_NORMAL Normal value (none of the above)

    These macro constants of type int are defined in header cmath

  • Note that each value pertains to a single category: for fpclassify, zero is not a normal value.
  • the return type is not int : it is the integral signed type associated to the floating entry type.
Decorators
  • std_ for floating entries call std::fpclassify and returns int
See also
is_eqz, is_denormal, is_normal, is_inf, is_nan
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::fpclassify(pf) = " << bs::fpclassify(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::fpclassify(xf) = " << bs::fpclassify(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::fpclassify(pf) = (4, 4, 4, 4)
---- scalar
<- xf = 2
-> bs::fpclassify(xf) = 4