Loading [MathJax]/extensions/tex2jax.js
E.V.E
v2023.02.15
 
All Classes Namespaces Functions Variables Typedefs Enumerations Friends Modules Pages Concepts
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 unsigned_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:116
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition: value.hpp:84
constexpr auto significants
Computes the rounding to n significants digits of the first input.
Definition: significants.hpp:66
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

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
#include <iomanip>
int main()
{
eve::wide<std::uint32_t, eve::fixed<8>> qi = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
float pf = 1.2345678901f;
std::cout << std::setprecision(10);
std::cout << "<- pf = " << pf << "\n";
std::cout << "<- qi = " << qi << "\n";
std::cout << std::setprecision(8);
std::cout << "-> significants(pf, qi)= " << eve::significants(pf, qi) << "\n";
}
Wrapper for SIMD registers.
Definition: wide.hpp:93