| 1 | #pragma once |
| 2 | |
| 3 | #include "setup.hpp" |
| 4 | |
| 5 | #if GLM_COMPILER == GLM_COMPILER_VC12 |
| 6 | # pragma warning(push) |
| 7 | # pragma warning(disable: 4512) |
| 8 | #endif |
| 9 | |
| 10 | namespace glm{ |
| 11 | namespace detail |
| 12 | { |
| 13 | template <typename T> |
| 14 | union float_t |
| 15 | {}; |
| 16 | |
| 17 | |
| 18 | template <> |
| 19 | union float_t<float> |
| 20 | { |
| 21 | typedef int int_type; |
| 22 | typedef float float_type; |
| 23 | |
| 24 | GLM_CONSTEXPR float_t(float_type Num = 0.0f) : f(Num) {} |
| 25 | |
| 26 | GLM_CONSTEXPR float_t& operator=(float_t const& x) |
| 27 | { |
| 28 | f = x.f; |
| 29 | return *this; |
| 30 | } |
| 31 | |
| 32 | |
| 33 | GLM_CONSTEXPR bool negative() const { return i < 0; } |
| 34 | GLM_CONSTEXPR int_type mantissa() const { return i & ((1 << 23) - 1); } |
| 35 | GLM_CONSTEXPR int_type exponent() const { return (i >> 23) & ((1 << 8) - 1); } |
| 36 | |
| 37 | int_type i; |
| 38 | float_type f; |
| 39 | }; |
| 40 | |
| 41 | template <> |
| 42 | union float_t<double> |
| 43 | { |
| 44 | typedef detail::int64 int_type; |
| 45 | typedef double float_type; |
| 46 | |
| 47 | GLM_CONSTEXPR float_t(float_type Num = static_cast<float_type>(0)) : f(Num) {} |
| 48 | |
| 49 | GLM_CONSTEXPR float_t& operator=(float_t const& x) |
| 50 | { |
| 51 | f = x.f; |
| 52 | return *this; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | GLM_CONSTEXPR bool negative() const { return i < 0; } |
| 57 | GLM_CONSTEXPR int_type mantissa() const { return i & ((int_type(1) << 52) - 1); } |
| 58 | GLM_CONSTEXPR int_type exponent() const { return (i >> 52) & ((int_type(1) << 11) - 1); } |
| 59 | |
| 60 | int_type i; |
| 61 | float_type f; |
| 62 | }; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | #if GLM_COMPILER == GLM_COMPILER_VC12 |
| 67 | # pragma warning(pop) |
| 68 | #endif |