Added vector retionnal with max ULPs arguments and fixed double support
This commit is contained in:
@@ -206,18 +206,5 @@ namespace detail
|
||||
return genType(1);
|
||||
}
|
||||
};
|
||||
|
||||
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
union float_t
|
||||
{
|
||||
GLM_CONSTEXPR float_t(float Num = 0.0f) : f(Num) {}
|
||||
// Portable extraction of components.
|
||||
GLM_CONSTEXPR bool negative() const { return i < 0; }
|
||||
GLM_CONSTEXPR int mantissa() const { return i & ((1 << 23) - 1); }
|
||||
GLM_CONSTEXPR int exponent() const { return (i >> 23) & 0xFF; }
|
||||
|
||||
int const i;
|
||||
float const f;
|
||||
};
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
48
glm/detail/type_float.hpp
Normal file
48
glm/detail/type_float.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "setup.hpp"
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
union float_t
|
||||
{};
|
||||
|
||||
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
template <>
|
||||
union float_t<float>
|
||||
{
|
||||
typedef int int_type;
|
||||
typedef float float_type;
|
||||
|
||||
GLM_CONSTEXPR float_t(float_type Num = 0.0f) : f(Num) {}
|
||||
|
||||
// Portable extraction of components.
|
||||
GLM_CONSTEXPR bool negative() const { return i < 0; }
|
||||
GLM_CONSTEXPR int_type mantissa() const { return i & ((1 << 23) - 1); }
|
||||
GLM_CONSTEXPR int_type exponent() const { return (i >> 23) & ((1 << 8) - 1); }
|
||||
|
||||
int_type const i;
|
||||
float_type const f;
|
||||
};
|
||||
|
||||
template <>
|
||||
union float_t<double>
|
||||
{
|
||||
typedef detail::int64 int_type;
|
||||
typedef double float_type;
|
||||
|
||||
GLM_CONSTEXPR float_t(float_type Num = static_cast<float_type>(0)) : f(Num) {}
|
||||
|
||||
// Portable extraction of components.
|
||||
GLM_CONSTEXPR bool negative() const { return i < 0; }
|
||||
GLM_CONSTEXPR int_type mantissa() const { return i & ((int_type(1) << 52) - 1); }
|
||||
GLM_CONSTEXPR int_type exponent() const { return (i >> 52) & ((int_type(1) << 11) - 1); }
|
||||
|
||||
int_type const i;
|
||||
float_type const f;
|
||||
};
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
Reference in New Issue
Block a user