Skip to content

Commit

Permalink
Fix bug where NaN was not being handled in signbit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Feb 28, 2024
1 parent 6e4fdfc commit 00d7edd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/ccmath/detail/compare/signbit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include "ccmath/detail/compare/isnan.hpp"

// If we have C++23, we can use std::signbit as it is constexpr
#if (defined(__cpp_lib_constexpr_cmath) && __cpp_lib_constexpr_cmath >= 202202L)
#include <cmath>
Expand Down Expand Up @@ -67,7 +69,7 @@ namespace ccm
#elif defined(CCMATH_HAS_CONSTEXPR_BUILTIN_COPYSIGN)
// use __builtin_copysign to check for the sign of zero

if (x == 0)
if (x == 0 || ccm::isnan(x))
{
if (__builtin_copysign(1.0, x) < 0) { return true; }

Expand Down

0 comments on commit 00d7edd

Please sign in to comment.