Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect constexpr in Imath::limits<half>, and missing test. #76

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Imath/ImathHalfLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ IMATH_INTERNAL_NAMESPACE_HEADER_ENTER

template <> struct limits<half>
{
constexpr static constexpr float min() noexcept { return -HALF_MAX; }
constexpr static constexpr float max() noexcept { return HALF_MAX; }
constexpr static constexpr float smallest() noexcept { return HALF_MIN; }
constexpr static constexpr float epsilon() noexcept { return HALF_EPSILON; }
constexpr static constexpr bool isIntegral() noexcept { return false; }
constexpr static constexpr bool isSigned() noexcept { return true; }
IMATH_HOSTDEVICE static constexpr float min() noexcept { return -HALF_MAX; }
IMATH_HOSTDEVICE static constexpr float max() noexcept { return HALF_MAX; }
IMATH_HOSTDEVICE static constexpr float smallest() noexcept { return HALF_MIN; }
IMATH_HOSTDEVICE static constexpr float epsilon() noexcept { return HALF_EPSILON; }
IMATH_HOSTDEVICE static constexpr bool isIntegral() noexcept { return false; }
IMATH_HOSTDEVICE static constexpr bool isSigned() noexcept { return true; }
};

IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Expand Down
16 changes: 16 additions & 0 deletions src/ImathTest/testLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include "halfLimits.h"
#include "ImathHalfLimits.h"
#include <assert.h>
#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -111,3 +112,18 @@ testLimits()

cout << "ok\n\n" << flush;
}

void
testHalfLimits()
{
cout << "values in Imath::limits<half>\n";

assert (Imath::limits<half>::min() == float (-HALF_MAX));
assert (Imath::limits<half>::max() == float (HALF_MAX));
assert (Imath::limits<half>::smallest() == float (HALF_MIN));
assert (Imath::limits<half>::epsilon() == float (HALF_EPSILON));
assert (Imath::limits<half>::isIntegral() == false);
assert (Imath::limits<half>::isSigned() == true);

cout << "ok\n\n" << flush;
}