E.V.E  0.1-beta

◆ frexp

eve::frexp = {}
inlineconstexpr

Callable object computing the frexp pair of values.

Required header: #include <eve/function/frexp.hpp>

Members Functions

Member Effect
operator() the computation of the frexp pair of values

auto operator()(floating_value auto x) const noexcept;
Definition: value.hpp:83

Parameters

x: floating_real_value.

Return value

Computes the elementwise ieee frexp of the floating value, returning a pair {m,e} of values of the same type of x which are related by \(x = m\times 2^e\), with \(|m| \in [0.5, 1.5[\).

However, the cases \(x = \pm\infty\) or is a Nan or a denormal are undefined.

Supported decorators

  • eve::pedantic

    Required header: #include <eve/function/pedantic/frexp.hpp>

    The call pedantic(frexp)(x) takes also properly care of the cases where \(x = \pm0, \pm\infty\) or is a Nan, where \(m=x\) and \(e=0\) and of the denormal cases.

Example

See it live on Compiler Explorer

#include <eve/function/frexp.hpp>
#include <eve/function/pedantic/frexp.hpp>
#include <eve/wide.hpp>
#include <eve/constant/mindenormal.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/nan.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 0.0f, 367.0f, -1005600.0f, eve::mindenormal(eve::as<double>()),
auto [m, e] = eve::frexp(pf);
auto [mp, ep] = eve::pedantic(eve::frexp)(pf);
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> frexp(pf) = [" << '\n'
<< " " << m << ", \n"
<< " " << e << '\n'
<< " ]\n"
<< "-> pedantic(frexp)(pf) = [" << '\n'
<< " " << mp << ", \n"
<< " " << ep << '\n'
<< " ]\n";
float xf = 2.3;
auto [sm, se] = eve::frexp(xf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> frexp(xf) = [" << sm << ", " << se << "]\n";
return 0;
}
constexpr callable_nan_ nan
Callable object computing the nan value.
Definition: nan.hpp:52
constexpr callable_minf_ minf
Callable object computing the negative infinity value.
Definition: minf.hpp:55
constexpr callable_mindenormal_ mindenormal
Callable object computing the least denormal positive value.
Definition: mindenormal.hpp:56
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
constexpr callable_frexp_ frexp
Callable object computing the frexp pair of values.
Definition: frexp.hpp:66
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65