Skip to content

Commit

Permalink
fix: std::isnan compilation fixed for freestanding and C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Feb 5, 2025
1 parent 8843982 commit e5d2b95
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/static/limits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import std;
#else
#include <limits>
#if MP_UNITS_HOSTED
#include <cmath>
#endif // MP_UNITS_HOSTED
#endif

namespace {
Expand Down Expand Up @@ -94,12 +97,16 @@ static_assert(std::numeric_limits<q_double>::infinity().numerical_value_in(mp_un
static_assert(std::numeric_limits<q_int>::infinity().numerical_value_in(mp_units::si::metre) ==
std::numeric_limits<int>::infinity());

#if MP_UNITS_HOSTED && (__cpp_lib_constexpr_cmath || MP_UNITS_COMP_GCC)

// quiet_NaN
static_assert(std::isnan(std::numeric_limits<q_double>::quiet_NaN().numerical_value_in(mp_units::si::metre)));

// signaling_NaN
static_assert(std::isnan(std::numeric_limits<q_double>::signaling_NaN().numerical_value_in(mp_units::si::metre)));

#endif

// denorm_min
static_assert(std::numeric_limits<q_double>::denorm_min().numerical_value_in(mp_units::si::metre) ==
std::numeric_limits<double>::denorm_min());
Expand Down Expand Up @@ -171,6 +178,8 @@ static_assert(std::numeric_limits<qp_double>::infinity().quantity_from_zero().nu
static_assert(std::numeric_limits<qp_int>::infinity().quantity_from_zero().numerical_value_in(mp_units::si::metre) ==
std::numeric_limits<int>::infinity());

#if MP_UNITS_HOSTED && (__cpp_lib_constexpr_cmath || MP_UNITS_COMP_GCC)

// quiet_NaN
static_assert(
std::isnan(std::numeric_limits<qp_double>::quiet_NaN().quantity_from_zero().numerical_value_in(mp_units::si::metre)));
Expand All @@ -179,6 +188,8 @@ static_assert(
static_assert(std::isnan(
std::numeric_limits<qp_double>::signaling_NaN().quantity_from_zero().numerical_value_in(mp_units::si::metre)));

#endif

// denorm_min
static_assert(std::numeric_limits<qp_double>::denorm_min().quantity_from_zero().numerical_value_in(
mp_units::si::metre) == std::numeric_limits<double>::denorm_min());
Expand Down

0 comments on commit e5d2b95

Please sign in to comment.