Browse Source

Math: be consistent with not using long double on Emscripten.

pull/342/head
Vladimír Vondruš 7 years ago
parent
commit
ab0d7c5485
  1. 11
      src/Magnum/Math/TypeTraits.h

11
src/Magnum/Math/TypeTraits.h

@ -54,6 +54,7 @@ for more headroom.
#define DOUBLE_EQUALITY_PRECISION 1.0e-14 #define DOUBLE_EQUALITY_PRECISION 1.0e-14
#endif #endif
#ifndef CORRADE_TARGET_EMSCRIPTEN
/** /**
@brief Precision when testing long doubles for equality @brief Precision when testing long doubles for equality
@ -63,7 +64,10 @@ for more headroom.
@attention On MSVC the precision is the same as for doubles, because they are @attention On MSVC the precision is the same as for doubles, because they are
internally the same type (source: https://msdn.microsoft.com/en-us/library/9cx8xs15.aspx). internally the same type (source: https://msdn.microsoft.com/en-us/library/9cx8xs15.aspx).
The same is apparently for 32-bit @ref CORRADE_TARGET_ANDROID "Android" The same is apparently for 32-bit @ref CORRADE_TARGET_ANDROID "Android"
(64-bit works as expected), but I couldn't find any source for that. (64-bit works as expected), but I couldn't find any source for that. This
macro (and everything else related to @cpp long double @ce types is not
available on @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" as the max
supported floating-point precision there is 64 bits.
*/ */
#ifndef LONG_DOUBLE_EQUALITY_PRECISION #ifndef LONG_DOUBLE_EQUALITY_PRECISION
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__) #if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__)
@ -72,6 +76,7 @@ for more headroom.
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14 #define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14
#endif #endif
#endif #endif
#endif
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
@ -341,7 +346,9 @@ namespace Implementation {
#endif #endif
_c(Float) _c(Float)
_c(Double) _c(Double)
#ifndef CORRADE_TARGET_EMSCRIPTEN
_c(long double) _c(long double)
#endif
#undef _c #undef _c
#endif #endif
@ -431,11 +438,13 @@ template<> struct TypeTraits<Double>: Implementation::TypeTraitsFloatingPoint<Do
constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; } constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; }
}; };
#ifndef CORRADE_TARGET_EMSCRIPTEN
template<> struct TypeTraits<long double>: Implementation::TypeTraitsFloatingPoint<long double> { template<> struct TypeTraits<long double>: Implementation::TypeTraitsFloatingPoint<long double> {
typedef long double FloatingPointType; typedef long double FloatingPointType;
constexpr static long double epsilon() { return LONG_DOUBLE_EQUALITY_PRECISION; } constexpr static long double epsilon() { return LONG_DOUBLE_EQUALITY_PRECISION; }
}; };
#endif
namespace Implementation { namespace Implementation {

Loading…
Cancel
Save