◆ tofloat()

as_floating_t<Value> boost::simd::tofloat ( Value const &  x)

This function object converts its parameter to floating point value occupying the same bit size.

This implies that this functor is only defined for (smd vectors of) 32 or 64 bit integer entries to provide (smd vectors of) float and or double.

See also
toint, touint, cast
Header <boost/simd/function/tofloat.hpp>
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/valmax.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_it = bs::pack <std::int32_t,4>;
int main()
{
pack_it pi = {-1, 2, -3, bs::Valmax<std::int32_t>() };
std::cout
<< "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bs::tofloat(pi) = " << bs::tofloat(pi) << '\n';
std::int16_t xi = -2;
std::cout
<< "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::tofloat(xi) = " << bs::tofloat(xi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (-1, 2, -3, 2147483647)
-> bs::tofloat(pi) = (-1, 2, -3, 2.14748e+09)
---- scalar
<- xi = -2
-> bs::tofloat(xi) = -2