Browse Source

Math: long double is the same as double also on Android.

pull/187/head^2
Vladimír Vondruš 10 years ago
parent
commit
210949f2dd
  1. 10
      src/Magnum/Math/Test/TypeTraitsTest.cpp
  2. 9
      src/Magnum/Math/TypeTraits.h

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

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

9
src/Magnum/Math/TypeTraits.h

@ -59,12 +59,13 @@ for more headroom.
They have "at least" 18 significant digits of precision, taking one digit less They have "at least" 18 significant digits of precision, taking one digit less
for more headroom. for more headroom.
@attention On MSVC the precision is the same as for doubles, because @attention On MSVC the precision is the same as for doubles, because they are
they are internally the same type. Source: internally the same type (source: https://msdn.microsoft.com/en-us/library/9cx8xs15.aspx).
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.
*/ */
#ifndef LONG_DOUBLE_EQUALITY_PRECISION #ifndef LONG_DOUBLE_EQUALITY_PRECISION
#ifndef _MSC_VER #if !defined(_MSC_VER) && !defined(CORRADE_TARGET_ANDROID)
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-17l #define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-17l
#else #else
#define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14l #define LONG_DOUBLE_EQUALITY_PRECISION 1.0e-14l

Loading…
Cancel
Save