E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ significants

eve::significants = functor<significants_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto significants(auto floating_value x, auto value n) noexcept;
}
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition: value.hpp:95
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition: value.hpp:33
constexpr auto significants
Computes the rounding to n significants digits of the first input.
Definition: significants.hpp:68
EVE Main Namespace.
Definition: abi.hpp:18

Parameters

Return value

Computes elementwise the rounding to n significants digits of x. With null n the result is a NaN.

Warning
Floating numbers are not stored in decimal form. So if you try significants with a not exactly representable number the result can be not exactly what you expect.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
using iT = std::int32_t;
using wide_it = eve::wide<iT, eve::fixed<4>>;
int main()
{
wide_it qi = {0, 1, 2, 4};
wide_ft pf = {1.2345678901f, 1.2345678901f, 1.2345678901f, 1.2345678901f};
std::cout << "---- simd" << std::setprecision(8) << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
<< "-> significants(pf, qi) = " << eve::significants(pf, qi) << '\n';
float xf = 2.34316;
iT yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yi = " << yi << '\n'
<< "-> significants(xf, yi) = " << eve::significants(xf, yi) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:71