Simple-Utility v2.3.1
Loading...
Searching...
No Matches
math

Classes

struct  sl::math::remquo_result< T >
 Result type for the remquo operation. More...
 
struct  sl::math::frexp_result< T >
 Result type for the frexp operation. More...
 
struct  sl::math::modf_result< T >
 Result type for the modf operation. More...
 

Functions

template<class T >
 sl::math::remquo_result (T, int) -> remquo_result< T >
 Manual deduction guide for the remquo_result type.
 
template<class T >
 sl::math::frexp_result (T, int) -> frexp_result< T >
 Manual deduction guide for the frexp_result type.
 

Variables

constexpr auto sl::math::remquo
 Computes the floating-point remainder of the division operation x/y. Additionally, the sign and at least the three of the last bits of x/y will be determined, sufficient to determine the octant of the result within a period.
 
constexpr auto sl::math::frexp
 Decomposes given floating point value into a normalized fraction and an integral power of two.
 
constexpr auto sl::math::modf
 Decomposes given floating point value into integral and fractional parts, each having the same type and sign as the original value.
 

Detailed Description

Function Documentation

◆ frexp_result()

template<class T >
sl::math::frexp_result ( ,
int   
) -> frexp_result< T >

Manual deduction guide for the frexp_result type.

Template Parameters
TUsed floating point type.
Note
Several clang versions require this to be present.

◆ remquo_result()

template<class T >
sl::math::remquo_result ( ,
int   
) -> remquo_result< T >

Manual deduction guide for the remquo_result type.

Template Parameters
TUsed floating point type.
Note
Several clang versions require this to be present.

Variable Documentation

◆ frexp

constexpr auto sl::math::frexp
constexpr
Initial value:
= [](const auto value) SL_CONSTEXPR_MATH
requires requires { std::frexp(value, nullptr); }
{
int exp{};
const auto fraction{std::frexp(value, &exp)};
return frexp_result{fraction, exp};
}
Checks whether the given template type is usable as value type for unique_handle types.
Definition: unique_handle.hpp:161
#define SL_CONSTEXPR_MATH
Definition: math.hpp:17

Decomposes given floating point value into a normalized fraction and an integral power of two.

Template Parameters
TUsed floating point type
Parameters
valueThe value to decompose.
Returns
Returns the result as frexp_result type.

This function is a more convenient version of the std::frexp function and simply forwards the call to that.

◆ modf

constexpr auto sl::math::modf
constexpr
Initial value:
= []<std::floating_point T>(const T value) SL_CONSTEXPR_MATH
{
T integral{};
T fraction{std::modf(value, &integral)};
return modf_result<T>{integral, fraction};
}

Decomposes given floating point value into integral and fractional parts, each having the same type and sign as the original value.

Template Parameters
TUsed floating point type
Parameters
valueThe value to decompose.
Returns
Returns the result as modf_result type.

This function is a more convenient version of the std::modf function and simply forwards the call to that.

◆ remquo

constexpr auto sl::math::remquo
constexpr
Initial value:
= [](const auto x, const auto y) SL_CONSTEXPR_MATH
requires requires { std::remquo(x, x, nullptr); }
{
int quo{};
const auto remainder{std::remquo(x, y, &quo)};
return remquo_result{remainder, quo};
}

Computes the floating-point remainder of the division operation x/y. Additionally, the sign and at least the three of the last bits of x/y will be determined, sufficient to determine the octant of the result within a period.

Parameters
xFirst floating point value.
ySecond floating point value.
Attention
y must not be equal to 0.
Returns
Returns the result as remquo_result type.

This function is a more convenient version of the std::remquo function and simply forwards the call to that.