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

◆ max_safe_integer

auto eve::max_safe_integer = functor<max_safe_integer_t>
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<eve::floating_value T> constexpr T max_safe_integer(as<T> x) noexcept;
}
constexpr auto max_safe_integer
Computes the greatest floating point representing an integer such that n != n+1.
Definition max_safe_integer.hpp:70
EVE Main Namespace.
Definition abi.hpp:19
Lightweight type-wrapper.
Definition as.hpp:29

Parameters

  • x : Type wrapper instance embedding the type of the constant.

Return value

The call eve::max_safe_integer(as<T>()) is semantically equivalent to:

  • T(2047.0f) if eve::element_type_t<T> is float16.
  • T(16777215.0f) if eve::element_type_t<T> is float.
  • T(9007199254740991.0) if eve::element_type_t<T> is double.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
using wide_ft = eve::wide<float>;
template<typename T>
consteval auto constexpr_max_safe_integer() { return eve::max_safe_integer(eve::as<T>{}); }
int main()
{
wide_ft wxf;
std::cout << "---- simd" << std::endl
<< "-> max_safe_integer(as<wide_ft>()) = " << eve::max_safe_integer(eve::as<wide_ft>()) << std::endl
<< "-> max_safe_integer(as(wxf)) = " << eve::max_safe_integer(eve::as(wxf)) << std::endl;
double xf;
std::cout << "---- scalar" << std::endl
<< "-> max_safe_integer(as<float>()) = " << std::setprecision(17) << eve::max_safe_integer(eve::as(float())) << std::endl
<< "-> max_safe_integer(as<xf)) = " << std::setprecision(17) << eve::max_safe_integer(eve::as(xf)) << std::endl;
std::cout << "-> constexpr max_safe_integer = " << constexpr_max_safe_integer<float>() << std::endl;
return 0;
}
Wrapper for SIMD registers.
Definition wide.hpp:94