From 00d7edd4af4fb30977c7959d70f24668c7e350bd Mon Sep 17 00:00:00 2001 From: Rinzii Date: Wed, 28 Feb 2024 17:49:24 -0500 Subject: [PATCH] Fix bug where NaN was not being handled in signbit --- include/ccmath/detail/compare/signbit.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ccmath/detail/compare/signbit.hpp b/include/ccmath/detail/compare/signbit.hpp index f413d5b..71a66ee 100644 --- a/include/ccmath/detail/compare/signbit.hpp +++ b/include/ccmath/detail/compare/signbit.hpp @@ -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 @@ -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; }