1#ifndef TDLS_CORE_STRUCTURAL_REAL_HPP
2#define TDLS_CORE_STRUCTURAL_REAL_HPP
70 static_assert(std::is_floating_point_v<T>,
"tdls::StructuralReal: T must be floating-point");
101 if (v == T(0))
return;
107 if (v != v || v * T(0.5) == v) {
114 constexpr T big = T(1LL << 62);
117 while (a >= big || a <= -big) {
121 while (T(
static_cast<long long>(a)) != a) {
123 if (a >= big || a <= -big) {
131 long long m =
static_cast<long long>(a);
132 while ((m & 1LL) == 0) {
Toolchain detection and portability macros.
#define TDLS_HOST_DEVICE
__host__ __device__ under CUDA, the equivalent attributes under HIP, empty elsewhere.
Definition macros.hpp:45
Floating-point value stored as an odd integer mantissa and a power-of-two exponent,...
Definition structural_real.hpp:68
long long mantissa
odd integer mantissa, 0 for the value zero
Definition structural_real.hpp:72
TDLS_HOST_DEVICE constexpr StructuralReal(const T v) noexcept
Exact decomposition of a finite value into m * 2^e.
Definition structural_real.hpp:100
TDLS_HOST_DEVICE constexpr bool is_finite() const noexcept
Whether the stored value is representable (a NaN, an infinity or a mantissa wider than 63 bits given ...
Definition structural_real.hpp:144
constexpr StructuralReal() noexcept=default
The value zero.
int exponent
power-of-two exponent: value = mantissa * 2^exponent
Definition structural_real.hpp:73