diff --git a/src/Math/Functions.h b/src/Math/Functions.h index e1b5582e7..dc2ff22e6 100644 --- a/src/Math/Functions.h +++ b/src/Math/Functions.h @@ -231,11 +231,11 @@ value in range @f$ [0, 1] @f$ or from *signed* integral to range @f$ [-1, 1] @f$ literals, this function should be called with both template parameters explicit, e.g.: @code -// Even if this is character literal, integral type is 32bit, thus a != 1.0f -float a = normalize('\127'); +// Literal type is (signed) char, but we assumed unsigned char, a != 1.0f +float a = normalize('\xFF'); // b = 1.0f -float b = normalize('\127'); +float b = normalize('\xFF'); @endcode @see denormalize() diff --git a/src/Math/Test/FunctionsTest.cpp b/src/Math/Test/FunctionsTest.cpp index c0d8e2809..e0858e566 100644 --- a/src/Math/Test/FunctionsTest.cpp +++ b/src/Math/Test/FunctionsTest.cpp @@ -37,6 +37,8 @@ class FunctionsTest: public Corrade::TestSuite::Tester { void renormalizeUnsinged(); void renormalizeSinged(); + void normalizeTypeDeduction(); + void pow(); void log(); void log2(); @@ -65,6 +67,8 @@ FunctionsTest::FunctionsTest() { &FunctionsTest::renormalizeUnsinged, &FunctionsTest::renormalizeSinged, + &FunctionsTest::normalizeTypeDeduction, + &FunctionsTest::pow, &FunctionsTest::log, &FunctionsTest::log2, @@ -233,6 +237,11 @@ void FunctionsTest::renormalizeSinged() { CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); } +void FunctionsTest::normalizeTypeDeduction() { + CORRADE_COMPARE(Math::normalize('\x7F'), 1.0f); + CORRADE_COMPARE((Math::normalize('\x7F')), 1.0f); +} + void FunctionsTest::pow() { CORRADE_COMPARE(Math::pow<10>(2ul), 1024ul); CORRADE_COMPARE(Math::pow<0>(3ul), 1ul);