diff --git a/include/ccmath/math/basic/impl/nan_double_impl.hpp b/include/ccmath/math/basic/impl/nan_double_impl.hpp index 84ac1779..f92e3a11 100644 --- a/include/ccmath/math/basic/impl/nan_double_impl.hpp +++ b/include/ccmath/math/basic/impl/nan_double_impl.hpp @@ -48,21 +48,7 @@ namespace ccm::internal // This is a patch to fix that issue. // Check that the last character is 1 and no other characters have been provided other than zero. - for (std::size_t i = 0; arg[i] != '\0'; ++i) // NOLINT - { - if (arg[i] != '0') - { - msvc_one_digit_patch = false; - break; - } - - if (arg[i] == '1' && arg[i + 1] == '\0') - { - msvc_one_digit_patch = true; - } - - msvc_one_digit_patch = false; - } + msvc_one_digit_patch = true; #endif if (!has_hex_been_detected) diff --git a/test/basic/nan_test.cpp b/test/basic/nan_test.cpp index 1bcf6324..997596c5 100644 --- a/test/basic/nan_test.cpp +++ b/test/basic/nan_test.cpp @@ -40,6 +40,11 @@ TEST(CcmathBasicTests, NanDouble) stdNanBits = ccm::helpers::bit_cast(std::nan("1")); EXPECT_EQ(ccmNanBits, stdNanBits); + // Check the outcome if we are handling a string with a single character that represents a number + ccmNanBits = ccm::helpers::bit_cast(ccm::nan("2")); + stdNanBits = ccm::helpers::bit_cast(std::nan("2")); + EXPECT_EQ(ccmNanBits, stdNanBits); + // Check the outcome if we are handling a string with a single character that represents a letter ccmNanBits = ccm::helpers::bit_cast(ccm::nan("a")); stdNanBits = ccm::helpers::bit_cast(std::nan("a")); @@ -65,6 +70,16 @@ TEST(CcmathBasicTests, NanDouble) stdNanBits = ccm::helpers::bit_cast(std::nan("000000000000000000000000000000000000000000000000000000001")); EXPECT_EQ(ccmNanBits, stdNanBits); + // Check the outcome if we are handling a string with a hex prefix and a single character + ccmNanBits = ccm::helpers::bit_cast(ccm::nan("0x2")); + stdNanBits = ccm::helpers::bit_cast(std::nan("0x2")); + EXPECT_EQ(ccmNanBits, stdNanBits); + + // Check for multi-digit wrapping + ccmNanBits = ccm::helpers::bit_cast(ccm::nan("000000000000000000000000000000000000000000000000000000002")); + stdNanBits = ccm::helpers::bit_cast(std::nan("000000000000000000000000000000000000000000000000000000002")); + EXPECT_EQ(ccmNanBits, stdNanBits); + // TODO: Correct these test cases. /** These currently fail. Likely due to the fact that we are not handling overflow.