diff --git a/libc/src/math/generic/asinf.cpp b/libc/src/math/generic/asinf.cpp index ee8e853063644e..7655aabb72101f 100644 --- a/libc/src/math/generic/asinf.cpp +++ b/libc/src/math/generic/asinf.cpp @@ -109,7 +109,7 @@ LLVM_LIBC_FUNCTION(float, asinf, (float x)) { fputil::set_errno_if_required(EDOM); fputil::raise_except_if_required(FE_INVALID); } - return x + FPBits::build_nan(Sign::POS, FPBits::FRACTION_MASK).get_val(); + return FPBits::build_quiet_nan().get_val(); } // Check for exceptional values diff --git a/libc/src/math/generic/sincosf.cpp b/libc/src/math/generic/sincosf.cpp index f12b93a0e69653..52f2323b435491 100644 --- a/libc/src/math/generic/sincosf.cpp +++ b/libc/src/math/generic/sincosf.cpp @@ -148,9 +148,7 @@ LLVM_LIBC_FUNCTION(void, sincosf, (float x, float *sinp, float *cosp)) { fputil::set_errno_if_required(EDOM); fputil::raise_except_if_required(FE_INVALID); } - *sinp = - x + - FPBits::build_nan(fputil::Sign::POS, FPBits::FRACTION_MASK).get_val(); + *sinp = FPBits::build_quiet_nan().get_val(); *cosp = *sinp; return; } diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 69da5387d382b5..7c81475ecec3ae 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -69,7 +69,7 @@ template struct FPTest : public Test { static constexpr T zero = FPBits::zero(Sign::POS).get_val(); static constexpr T neg_zero = FPBits::zero(Sign::NEG).get_val(); static constexpr T aNaN = FPBits::build_quiet_nan().get_val(); - static constexpr T sNaN = FPBits::build_nan(Sign::POS, 1).get_val(); + static constexpr T sNaN = FPBits::build_nan().get_val(); static constexpr T inf = FPBits::inf(Sign::POS).get_val(); static constexpr T neg_inf = FPBits::inf(Sign::NEG).get_val(); static constexpr T min_normal = FPBits::min_normal().get_val(); @@ -98,7 +98,7 @@ template struct FPTest : public Test { const T zero = FPBits::zero(Sign::POS).get_val(); \ const T neg_zero = FPBits::zero(Sign::NEG).get_val(); \ const T aNaN = FPBits::build_quiet_nan().get_val(); \ - const T sNaN = FPBits::build_nan(Sign::POS, 1).get_val(); \ + const T sNaN = FPBits::build_nan().get_val(); \ const T inf = FPBits::inf(Sign::POS).get_val(); \ const T neg_inf = FPBits::inf(Sign::NEG).get_val(); \ const T min_normal = FPBits::min_normal().get_val(); \ diff --git a/libc/test/src/__support/FPUtil/fpbits_test.cpp b/libc/test/src/__support/FPUtil/fpbits_test.cpp index aadcd3fe92b9e5..a4324a071536f8 100644 --- a/libc/test/src/__support/FPUtil/fpbits_test.cpp +++ b/libc/test/src/__support/FPUtil/fpbits_test.cpp @@ -236,8 +236,7 @@ TEST(LlvmLibcFPBitsTest, FloatType) { "(+Infinity)"); EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits::inf(Sign::NEG)).c_str(), "(-Infinity)"); - EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits::build_nan(Sign::POS, 1)).c_str(), - "(NaN)"); + EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits::build_nan()).c_str(), "(NaN)"); FloatBits zero(0.0f); EXPECT_TRUE(zero.is_pos()); @@ -363,9 +362,8 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) { "(+Infinity)"); EXPECT_STREQ(LIBC_NAMESPACE::str(LongDoubleBits::inf(Sign::NEG)).c_str(), "(-Infinity)"); - EXPECT_STREQ( - LIBC_NAMESPACE::str(LongDoubleBits::build_nan(Sign::POS, 1)).c_str(), - "(NaN)"); + EXPECT_STREQ(LIBC_NAMESPACE::str(LongDoubleBits::build_nan()).c_str(), + "(NaN)"); LongDoubleBits zero(0.0l); EXPECT_TRUE(zero.is_pos()); @@ -444,9 +442,8 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) { "(+Infinity)"); EXPECT_STREQ(LIBC_NAMESPACE::str(LongDoubleBits::inf(Sign::NEG)).c_str(), "(-Infinity)"); - EXPECT_STREQ( - LIBC_NAMESPACE::str(LongDoubleBits::build_nan(Sign::POS, 1)).c_str(), - "(NaN)"); + EXPECT_STREQ(LIBC_NAMESPACE::str(LongDoubleBits::build_nan()).c_str(), + "(NaN)"); LongDoubleBits zero(0.0l); EXPECT_TRUE(zero.is_pos()); @@ -519,9 +516,7 @@ TEST(LlvmLibcFPBitsTest, Float128Type) { "(+Infinity)"); EXPECT_STREQ(LIBC_NAMESPACE::str(Float128Bits::inf(Sign::NEG)).c_str(), "(-Infinity)"); - EXPECT_STREQ( - LIBC_NAMESPACE::str(Float128Bits::build_nan(Sign::POS, 1)).c_str(), - "(NaN)"); + EXPECT_STREQ(LIBC_NAMESPACE::str(Float128Bits::build_nan()).c_str(), "(NaN)"); Float128Bits zero = Float128Bits::zero(Sign::POS); EXPECT_TRUE(zero.is_pos()); diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp index 07501ac751fa30..70cacf01a2f991 100644 --- a/libc/test/src/stdio/sprintf_test.cpp +++ b/libc/test/src/stdio/sprintf_test.cpp @@ -586,9 +586,8 @@ TEST(LlvmLibcSPrintfTest, OctConv) { TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) { ForceRoundingMode r(RoundingMode::Nearest); double inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - double nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + double nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); written = LIBC_NAMESPACE::sprintf(buff, "%a", 1.0); ASSERT_STREQ_LEN(written, buff, "0x1p+0"); @@ -952,14 +951,12 @@ TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) { TEST_F(LlvmLibcSPrintfTest, FloatDecimalConv) { ForceRoundingMode r(RoundingMode::Nearest); double inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - double nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + double nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); long double ld_inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - long double ld_nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + long double ld_nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); char big_buff[10000]; // Used for long doubles and other extremely wide // numbers. @@ -1808,9 +1805,8 @@ TEST_F(LlvmLibcSPrintfTest, FloatDecimalLongDoubleConv) { TEST_F(LlvmLibcSPrintfTest, FloatExponentConv) { ForceRoundingMode r(RoundingMode::Nearest); double inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - double nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + double nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); written = LIBC_NAMESPACE::sprintf(buff, "%e", 1.0); ASSERT_STREQ_LEN(written, buff, "1.000000e+00"); @@ -2417,9 +2413,8 @@ TEST_F(LlvmLibcSPrintfTest, FloatExponentLongDoubleConv) { TEST_F(LlvmLibcSPrintfTest, FloatAutoConv) { ForceRoundingMode r(RoundingMode::Nearest); double inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - double nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + double nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); written = LIBC_NAMESPACE::sprintf(buff, "%g", 1.0); ASSERT_STREQ_LEN(written, buff, "1"); diff --git a/libc/test/src/stdio/sscanf_test.cpp b/libc/test/src/stdio/sscanf_test.cpp index db67c25029133c..abfdb338323dcb 100644 --- a/libc/test/src/stdio/sscanf_test.cpp +++ b/libc/test/src/stdio/sscanf_test.cpp @@ -231,9 +231,8 @@ TEST(LlvmLibcSScanfTest, FloatConvSimple) { float result = 0; float inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - float nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + float nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); ret_val = LIBC_NAMESPACE::sscanf("123", "%f", &result); EXPECT_EQ(ret_val, 1); @@ -297,9 +296,8 @@ TEST(LlvmLibcSScanfTest, FloatConvLengthModifier) { long double ld_result = 0; double d_inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - long double ld_nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + long double ld_nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); ret_val = LIBC_NAMESPACE::sscanf("123", "%lf", &d_result); EXPECT_EQ(ret_val, 1); @@ -395,9 +393,8 @@ TEST(LlvmLibcSScanfTest, FloatConvComplexParsing) { float result = 0; float inf = LIBC_NAMESPACE::fputil::FPBits::inf().get_val(); - float nan = LIBC_NAMESPACE::fputil::FPBits::build_nan( - LIBC_NAMESPACE::fputil::Sign::POS, 1) - .get_val(); + float nan = + LIBC_NAMESPACE::fputil::FPBits::build_quiet_nan().get_val(); ret_val = LIBC_NAMESPACE::sscanf("0x1.0e3", "%f", &result); EXPECT_EQ(ret_val, 1);