Browse Source

Math: enlarge epsilon value for long doubles on MSVC.

They are internally treated as 64-bit doubles, so there's no difference.
pull/175/merge
Vladimír Vondruš 10 years ago
parent
commit
4a395ac490
  1. 24
      src/Magnum/Math/Test/TypeTraitsTest.cpp
  2. 8
      src/Magnum/Math/TypeTraits.h

24
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},
};
}

8
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 {

Loading…
Cancel
Save