From 4a395ac4907f26fd3636897ddaf5a371539576e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 1 Sep 2016 21:52:41 +0200 Subject: [PATCH] Math: enlarge epsilon value for long doubles on MSVC. They are internally treated as 64-bit doubles, so there's no difference. --- src/Magnum/Math/Test/TypeTraitsTest.cpp | 24 +++++++++++++++++++++--- src/Magnum/Math/TypeTraits.h | 8 ++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Math/Test/TypeTraitsTest.cpp b/src/Magnum/Math/Test/TypeTraitsTest.cpp index ff31c7ee6..fd34cfa06 100644 --- a/src/Magnum/Math/Test/TypeTraitsTest.cpp +++ b/src/Magnum/Math/Test/TypeTraitsTest.cpp @@ -68,9 +68,27 @@ struct { long double get(long double) const { return c; } long double getStep(long double) const { return cStep; } } EqualsZeroData[EqualsZeroDataCount] = { - {"", -3.141592653589793f, 5.0e-5f, -3.141592653589793, 5.0e-14, -3.141592653589793l, 5.0e-17l}, - {"small", 1.0e-6f, 5.0e-6f, -1.0e-15, 5.0e-15, 1.0e-18l, 5.0e-18l}, - {"large", 12345.0f, 0.2f, 12345678901234.0, 0.2, -12345678901234567.0l, 0.2l}, + {"", -3.141592653589793f, 5.0e-5f, -3.141592653589793, 5.0e-14, -3.141592653589793l, + #ifndef _MSC_VER + 5.0e-17l + #else + 5.0e-14 + #endif + }, + {"small", 1.0e-6f, 5.0e-6f, -1.0e-15, 5.0e-15, 1.0e-18l, + #ifndef _MSC_VER + 5.0e-18l + #else + 5.0e-15 + #endif + }, + {"large", 12345.0f, 0.2f, 12345678901234.0, 0.2, + #ifndef _MSC_VER + -12345678901234567.0l, + #else + -12345678901234.0l, + #endif + 0.2l}, }; } diff --git a/src/Magnum/Math/TypeTraits.h b/src/Magnum/Math/TypeTraits.h index 22d725c16..645e81612 100644 --- a/src/Magnum/Math/TypeTraits.h +++ b/src/Magnum/Math/TypeTraits.h @@ -58,9 +58,17 @@ for more headroom. They have "at least" 18 significant digits of precision, taking one digit less for more headroom. + +@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 */ #ifndef LONG_DOUBLE_EQUALITY_PRECISION +#ifndef _MSC_VER #define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-17l +#else +#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14l +#endif #endif namespace Magnum { namespace Math {