◆ significants()

IEEEValue boost::simd::significants ( IEEEValue const &  x,
IntegerValue const &  n 
)

This function object returns the rounding to n significants digits of its argument.

Header <boost/simd/function/signiicants.hpp>
Example:
#include <boost/simd/exponential.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using iT = std::int32_t;
using pack_it = bs::pack<iT, 4>;
using pack_ft = bs::pack<float, 4>;
int main() {
pack_ft pf(1234.567f);
pack_it qi = {1, 2, 3, 4};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
<< "-> bs::significants(pf, qi) = " << bs::significants(pf, qi)
<< '\n';
float xf = 2.345678f;
iT yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yi = " << yi << '\n'
<< "-> bs::significants(xf, yi) = " << bs::significants(xf, yi)
<< '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1234.57, 1234.57, 1234.57, 1234.57)
<- qi = (1, 2, 3, 4)
-> bs::significants(pf, qi) = (1000, 1200, 1230, 1235)
---- scalar
<- xf = 2.34568
<- yi = 3
-> bs::significants(xf, yi) = 2.35