diff --git a/src/Magnum/Math/Half.h b/src/Magnum/Math/Half.h index b131a4270..bddc9acd8 100644 --- a/src/Magnum/Math/Half.h +++ b/src/Magnum/Math/Half.h @@ -86,12 +86,21 @@ class Half { constexpr explicit Half(UnsignedShort data) noexcept: _data{data} {} /** - * @brief Construct a half value from 32-bit float representation + * @brief Construct a half value from a 32-bit float representation * * @see @ref packHalf() */ explicit Half(Float value) noexcept: _data{packHalf(value)} {} + /** + * @brief Construct a half value from a 64-bit float representation + * + * Present only to aid generic code so e.g. @cpp T(1.0) @ce works + * without being ambigous. + * @see @ref packHalf() + */ + explicit Half(Double value) noexcept: _data{packHalf(Float(value))} {} + /** @brief Construct without initializing the contents */ explicit Half(NoInitT) noexcept {} diff --git a/src/Magnum/Math/Test/HalfTest.cpp b/src/Magnum/Math/Test/HalfTest.cpp index 6e00b4558..3a27747a4 100644 --- a/src/Magnum/Math/Test/HalfTest.cpp +++ b/src/Magnum/Math/Test/HalfTest.cpp @@ -513,14 +513,20 @@ void HalfTest::constructDefault() { void HalfTest::constructValue() { Half a{3.5f}; + Half b{3.5}; CORRADE_COMPARE(Float(a), 3.5f); + CORRADE_COMPARE(Float(b), 3.5f); CORRADE_COMPARE(UnsignedShort(a), 0x4300); + CORRADE_COMPARE(UnsignedShort(b), 0x4300); CORRADE_COMPARE(a.data(), 0x4300); + CORRADE_COMPARE(b.data(), 0x4300); CORRADE_VERIFY((std::is_nothrow_constructible::value)); + CORRADE_VERIFY((std::is_nothrow_constructible::value)); /* Implicit conversion is not allowed */ CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } void HalfTest::constructData() {