Browse Source

Math: long double issues are now only on 32-bit Android.

pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
9793123fba
  1. 2
      src/Magnum/Math/Test/HalfTest.cpp
  2. 12
      src/Magnum/Math/Test/PackingTest.cpp
  3. 12
      src/Magnum/Math/Test/TypeTraitsTest.cpp
  4. 8
      src/Magnum/Math/TypeTraits.h

2
src/Magnum/Math/Test/HalfTest.cpp

@ -613,8 +613,6 @@ void HalfTest::debug() {
<< Math::Vector3<Half>{3.14159_h, -1.4142_h, 1.618_h};
#ifdef _MSC_VER
CORRADE_COMPARE(out.str(), "-3.64063 inf Vector(3.14063, -1.41406, 1.61816)\n");
#elif defined(CORRADE_TARGET_ANDROID)
CORRADE_COMPARE(out.str(), "-3.64062 Inf Vector(3.14062, -1.41406, 1.61816)\n");
#else
CORRADE_COMPARE(out.str(), "-3.64062 inf Vector(3.14062, -1.41406, 1.61816)\n");
#endif

12
src/Magnum/Math/Test/PackingTest.cpp

@ -159,8 +159,8 @@ void PackingTest::packUnsigned() {
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(Math::pack<UnsignedLong>(0.0l), 0);
{
#ifdef _MSC_VER
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC.");
#if defined(_MSC_VER) || (defined(CORRADE_TARGET_ANDROID) && !__LP64__)
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC and 32-bit Android.");
#endif
CORRADE_COMPARE(Math::pack<UnsignedLong>(1.0l), std::numeric_limits<UnsignedLong>::max());
}
@ -235,8 +235,8 @@ void PackingTest::reunpackUnsinged() {
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(Math::unpack<long double>(Math::pack<UnsignedLong>(0.0l)), 0.0l);
{
#ifdef _MSC_VER
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC.");
#if defined(_MSC_VER) || (defined(CORRADE_TARGET_ANDROID) && !__LP64__)
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC and 32-bit Android.");
#endif
CORRADE_COMPARE(Math::unpack<long double>(Math::pack<UnsignedLong>(1.0l)), 1.0l);
}
@ -260,8 +260,8 @@ void PackingTest::reunpackSinged() {
CORRADE_COMPARE(Math::unpack<long double>(Math::pack<Long>(-1.0l)), -1.0l);
CORRADE_COMPARE(Math::unpack<long double>(Math::pack<Long>(0.0l)), 0.0l);
{
#ifdef _MSC_VER
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC.");
#if defined(_MSC_VER) || (defined(CORRADE_TARGET_ANDROID) && !__LP64__)
CORRADE_EXPECT_FAIL("Long double (de)normalization is broken on MSVC and 32-bit Android.");
#endif
CORRADE_COMPARE(Math::unpack<long double>(Math::pack<Long>(1.0l)), 1.0l);
}

12
src/Magnum/Math/Test/TypeTraitsTest.cpp

@ -70,24 +70,24 @@ struct {
long double getStep(long double) const { return cStep; }
} EqualsZeroData[EqualsZeroDataCount] = {
{"", -3.141592653589793f, 5.0e-5f, -3.141592653589793, 5.0e-14, -3.141592653589793l,
#if !defined(_MSC_VER) && !defined(CORRADE_TARGET_ANDROID)
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__)
5.0e-17l
#else
5.0e-14
#endif
},
{"small", 1.0e-6f, 5.0e-6f, -1.0e-15, 5.0e-15, 1.0e-18l,
#if !defined(_MSC_VER) && !defined(CORRADE_TARGET_ANDROID)
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__)
5.0e-18l
#else
5.0e-15
#endif
},
{"large", 12345.0f, 0.2f, 12345678901234.0, 0.2,
#if !defined(_MSC_VER) && !defined(CORRADE_TARGET_ANDROID)
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__)
-12345678901234567.0l,
#else
-12345678901234.0l,
-12345678901234.0,
#endif
0.2l},
};
@ -154,9 +154,9 @@ void TypeTraitsTest::sizeOfLongDouble() {
#ifdef CORRADE_TARGET_EMSCRIPTEN
CORRADE_SKIP("Not defined in Emscripten.");
#else
#if defined(_MSC_VER) || defined(CORRADE_TARGET_ANDROID)
#if defined(_MSC_VER) || (defined(CORRADE_TARGET_ANDROID) && !__LP64__)
CORRADE_COMPARE(sizeof(long double), 8);
CORRADE_EXPECT_FAIL("long double is equivalent to double on MSVC and Android.");
CORRADE_EXPECT_FAIL("long double is equivalent to double on MSVC and 32-bit Android.");
#endif
/* It's 80 bit, but has to be aligned somehow, so 128 bits / 16 bytes */

8
src/Magnum/Math/TypeTraits.h

@ -61,14 +61,14 @@ 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).
The same is apparently for @ref CORRADE_TARGET_ANDROID "Android", but I
couldn't find any source for that.
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.
*/
#ifndef LONG_DOUBLE_EQUALITY_PRECISION
#if !defined(_MSC_VER) && !defined(CORRADE_TARGET_ANDROID)
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__)
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-17l
#else
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14l
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14
#endif
#endif

Loading…
Cancel
Save