11 changes: 5 additions & 6 deletions libc/src/math/generic/powf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,14 @@ LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
// pow(+-0, -Inf) = +inf and raise FE_DIVBYZERO
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_DIVBYZERO);
return FloatBits::inf().get_val();
return FloatBits::inf();
}
// pow (|x| < 1, -inf) = +inf
// pow (|x| < 1, +inf) = 0.0f
// pow (|x| > 1, -inf) = 0.0f
// pow (|x| > 1, +inf) = +inf
return ((x_abs < 0x3f80'0000) == (y_u == 0xff80'0000))
? FloatBits::inf().get_val()
: 0.0f;
return ((x_abs < 0x3f80'0000) == (y_u == 0xff80'0000)) ? FloatBits::inf()
: 0.0f;
}
default:
// Speed up for common exponents
Expand Down Expand Up @@ -619,7 +618,7 @@ LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
// pow(0, negative number) = inf
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_DIVBYZERO);
return FloatBits::inf(out_sign).get_val();
return FloatBits::inf(out_sign);
}
// pow(0, positive number) = 0
return out_sign ? -0.0f : 0.0f;
Expand All @@ -630,7 +629,7 @@ LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
if (y_u >= FloatProp::SIGN_MASK) {
return out_sign ? -0.0f : 0.0f;
}
return FloatBits::inf(out_sign).get_val();
return FloatBits::inf(out_sign);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/sinhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
fputil::set_errno_if_required(ERANGE);
fputil::raise_except_if_required(FE_OVERFLOW);

return x + FPBits::inf(sign).get_val();
return x + FPBits::inf(sign);
}

// sinh(x) = (e^x - e^(-x)) / 2.
Expand Down
31 changes: 21 additions & 10 deletions libc/test/UnitTest/FPMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ template <TestCond C, typename T> FPMatcher<T, C> getMatcher(T expectedValue) {
template <typename T> struct FPTest : public Test {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using UIntType = typename FPBits::UIntType;
static constexpr T zero = T(FPBits::zero());
static constexpr T neg_zero = T(FPBits::neg_zero());
static constexpr T aNaN = T(FPBits::build_quiet_nan(1));
static constexpr T inf = T(FPBits::inf());
static constexpr T neg_inf = T(FPBits::neg_inf());
static constexpr T zero = FPBits::zero();
static constexpr T neg_zero = FPBits::neg_zero();
static constexpr T aNaN = FPBits::build_quiet_nan(1);
static constexpr T sNaN = FPBits::build_nan(1);
static constexpr T inf = FPBits::inf();
static constexpr T neg_inf = FPBits::neg_inf();
static constexpr T min_normal = FPBits::min_normal();
static constexpr T max_normal = FPBits::max_normal();
static constexpr T min_denormal = FPBits::min_denormal();
static constexpr T max_denormal = FPBits::max_denormal();

static constexpr int N_ROUNDING_MODES = 4;
static constexpr fputil::testing::RoundingMode ROUNDING_MODES[4] = {
fputil::testing::RoundingMode::Nearest,
Expand All @@ -82,11 +88,16 @@ template <typename T> struct FPTest : public Test {
#define DECLARE_SPECIAL_CONSTANTS(T) \
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>; \
using UIntType = typename FPBits::UIntType; \
const T zero = T(FPBits::zero()); \
const T neg_zero = T(FPBits::neg_zero()); \
const T aNaN = T(FPBits::build_quiet_nan(1)); \
const T inf = T(FPBits::inf()); \
const T neg_inf = T(FPBits::neg_inf());
const T zero = FPBits::zero(); \
const T neg_zero = FPBits::neg_zero(); \
const T aNaN = FPBits::build_quiet_nan(1); \
const T sNaN = FPBits::build_nan(1); \
const T inf = FPBits::inf(); \
const T neg_inf = FPBits::neg_inf(); \
const T min_normal = FPBits::min_normal(); \
const T max_normal = FPBits::max_normal(); \
const T min_denormal = FPBits::min_denormal(); \
const T max_denormal = FPBits::max_denormal();

#define EXPECT_FP_EQ(expected, actual) \
EXPECT_THAT(actual, LIBC_NAMESPACE::testing::getMatcher< \
Expand Down
105 changes: 57 additions & 48 deletions libc/test/src/__support/FPUtil/fpbits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,56 @@
using LIBC_NAMESPACE::fputil::FPBits;

TEST(LlvmLibcFPBitsTest, FloatType) {
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<float>::inf()).c_str(),
using FloatBits = FPBits<float>;

EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits(FloatBits::inf())).c_str(),
"(+Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<float>::neg_inf()).c_str(),
EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits(FloatBits::neg_inf())).c_str(),
"(-Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(FPBits<float>(FPBits<float>::build_nan(1))).c_str(),
"(NaN)");
EXPECT_STREQ(LIBC_NAMESPACE::str(FloatBits(FloatBits::build_nan(1))).c_str(),
"(NaN)");

FPBits<float> zero(0.0f);
FloatBits zero(0.0f);
EXPECT_EQ(zero.get_sign(), false);
EXPECT_EQ(zero.get_unbiased_exponent(), static_cast<uint16_t>(0));
EXPECT_EQ(zero.get_mantissa(), static_cast<uint32_t>(0));
EXPECT_EQ(zero.uintval(), static_cast<uint32_t>(0x00000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(zero).c_str(),
"0x00000000 = (S: 0, E: 0x0000, M: 0x00000000)");

FPBits<float> negzero(-0.0f);
FloatBits negzero(-0.0f);
EXPECT_EQ(negzero.get_sign(), true);
EXPECT_EQ(negzero.get_unbiased_exponent(), static_cast<uint16_t>(0));
EXPECT_EQ(negzero.get_mantissa(), static_cast<uint32_t>(0));
EXPECT_EQ(negzero.uintval(), static_cast<uint32_t>(0x80000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(negzero).c_str(),
"0x80000000 = (S: 1, E: 0x0000, M: 0x00000000)");

FPBits<float> one(1.0f);
FloatBits one(1.0f);
EXPECT_EQ(one.get_sign(), false);
EXPECT_EQ(one.get_unbiased_exponent(), static_cast<uint16_t>(0x7F));
EXPECT_EQ(one.get_mantissa(), static_cast<uint32_t>(0));
EXPECT_EQ(one.uintval(), static_cast<uint32_t>(0x3F800000));
EXPECT_STREQ(LIBC_NAMESPACE::str(one).c_str(),
"0x3F800000 = (S: 0, E: 0x007F, M: 0x00000000)");

FPBits<float> negone(-1.0f);
FloatBits negone(-1.0f);
EXPECT_EQ(negone.get_sign(), true);
EXPECT_EQ(negone.get_unbiased_exponent(), static_cast<uint16_t>(0x7F));
EXPECT_EQ(negone.get_mantissa(), static_cast<uint32_t>(0));
EXPECT_EQ(negone.uintval(), static_cast<uint32_t>(0xBF800000));
EXPECT_STREQ(LIBC_NAMESPACE::str(negone).c_str(),
"0xBF800000 = (S: 1, E: 0x007F, M: 0x00000000)");

FPBits<float> num(1.125f);
FloatBits num(1.125f);
EXPECT_EQ(num.get_sign(), false);
EXPECT_EQ(num.get_unbiased_exponent(), static_cast<uint16_t>(0x7F));
EXPECT_EQ(num.get_mantissa(), static_cast<uint32_t>(0x00100000));
EXPECT_EQ(num.uintval(), static_cast<uint32_t>(0x3F900000));
EXPECT_STREQ(LIBC_NAMESPACE::str(num).c_str(),
"0x3F900000 = (S: 0, E: 0x007F, M: 0x00100000)");

FPBits<float> negnum(-1.125f);
FloatBits negnum(-1.125f);
EXPECT_EQ(negnum.get_sign(), true);
EXPECT_EQ(negnum.get_unbiased_exponent(), static_cast<uint16_t>(0x7F));
EXPECT_EQ(negnum.get_mantissa(), static_cast<uint32_t>(0x00100000));
Expand All @@ -71,55 +72,57 @@ TEST(LlvmLibcFPBitsTest, FloatType) {
}

TEST(LlvmLibcFPBitsTest, DoubleType) {
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<double>::inf()).c_str(),
using DoubleBits = FPBits<double>;

EXPECT_STREQ(LIBC_NAMESPACE::str(DoubleBits(DoubleBits::inf())).c_str(),
"(+Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<double>::neg_inf()).c_str(),
EXPECT_STREQ(LIBC_NAMESPACE::str(DoubleBits(DoubleBits::neg_inf())).c_str(),
"(-Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(FPBits<double>(FPBits<double>::build_nan(1))).c_str(),
LIBC_NAMESPACE::str(DoubleBits(DoubleBits::build_nan(1))).c_str(),
"(NaN)");

FPBits<double> zero(0.0);
DoubleBits zero(0.0);
EXPECT_EQ(zero.get_sign(), false);
EXPECT_EQ(zero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(zero.get_mantissa(), static_cast<uint64_t>(0x0000000000000000));
EXPECT_EQ(zero.uintval(), static_cast<uint64_t>(0x0000000000000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(zero).c_str(),
"0x0000000000000000 = (S: 0, E: 0x0000, M: 0x0000000000000000)");

FPBits<double> negzero(-0.0);
DoubleBits negzero(-0.0);
EXPECT_EQ(negzero.get_sign(), true);
EXPECT_EQ(negzero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(negzero.get_mantissa(), static_cast<uint64_t>(0x0000000000000000));
EXPECT_EQ(negzero.uintval(), static_cast<uint64_t>(0x8000000000000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(negzero).c_str(),
"0x8000000000000000 = (S: 1, E: 0x0000, M: 0x0000000000000000)");

FPBits<double> one(1.0);
DoubleBits one(1.0);
EXPECT_EQ(one.get_sign(), false);
EXPECT_EQ(one.get_unbiased_exponent(), static_cast<uint16_t>(0x03FF));
EXPECT_EQ(one.get_mantissa(), static_cast<uint64_t>(0x0000000000000000));
EXPECT_EQ(one.uintval(), static_cast<uint64_t>(0x3FF0000000000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(one).c_str(),
"0x3FF0000000000000 = (S: 0, E: 0x03FF, M: 0x0000000000000000)");

FPBits<double> negone(-1.0);
DoubleBits negone(-1.0);
EXPECT_EQ(negone.get_sign(), true);
EXPECT_EQ(negone.get_unbiased_exponent(), static_cast<uint16_t>(0x03FF));
EXPECT_EQ(negone.get_mantissa(), static_cast<uint64_t>(0x0000000000000000));
EXPECT_EQ(negone.uintval(), static_cast<uint64_t>(0xBFF0000000000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(negone).c_str(),
"0xBFF0000000000000 = (S: 1, E: 0x03FF, M: 0x0000000000000000)");

FPBits<double> num(1.125);
DoubleBits num(1.125);
EXPECT_EQ(num.get_sign(), false);
EXPECT_EQ(num.get_unbiased_exponent(), static_cast<uint16_t>(0x03FF));
EXPECT_EQ(num.get_mantissa(), static_cast<uint64_t>(0x0002000000000000));
EXPECT_EQ(num.uintval(), static_cast<uint64_t>(0x3FF2000000000000));
EXPECT_STREQ(LIBC_NAMESPACE::str(num).c_str(),
"0x3FF2000000000000 = (S: 0, E: 0x03FF, M: 0x0002000000000000)");

FPBits<double> negnum(-1.125);
DoubleBits negnum(-1.125);
EXPECT_EQ(negnum.get_sign(), true);
EXPECT_EQ(negnum.get_unbiased_exponent(), static_cast<uint16_t>(0x03FF));
EXPECT_EQ(negnum.get_mantissa(), static_cast<uint64_t>(0x0002000000000000));
Expand All @@ -130,19 +133,22 @@ TEST(LlvmLibcFPBitsTest, DoubleType) {

#ifdef LIBC_TARGET_ARCH_IS_X86
TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
using LongDoubleBits = FPBits<long double>;

if constexpr (sizeof(long double) == sizeof(double))
return; // The tests for the "double" type cover for this case.

EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<long double>::inf()).c_str(),
"(+Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<long double>::neg_inf()).c_str(),
"(-Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(
FPBits<long double>(FPBits<long double>::build_nan(1)))
.c_str(),
"(NaN)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::inf())).c_str(),
"(+Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::neg_inf())).c_str(),
"(-Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::build_nan(1))).c_str(),
"(NaN)");

FPBits<long double> zero(0.0l);
LongDoubleBits zero(0.0l);
EXPECT_EQ(zero.get_sign(), false);
EXPECT_EQ(zero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(zero.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -153,7 +159,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
"0x00000000000000000000000000000000 = "
"(S: 0, E: 0x0000, I: 0, M: 0x00000000000000000000000000000000)");

FPBits<long double> negzero(-0.0l);
LongDoubleBits negzero(-0.0l);
EXPECT_EQ(negzero.get_sign(), true);
EXPECT_EQ(negzero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(negzero.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -164,7 +170,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
"0x00000000000080000000000000000000 = "
"(S: 1, E: 0x0000, I: 0, M: 0x00000000000000000000000000000000)");

FPBits<long double> one(1.0l);
LongDoubleBits one(1.0l);
EXPECT_EQ(one.get_sign(), false);
EXPECT_EQ(one.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(one.get_mantissa(), static_cast<UInt128>(0x0000000000000000) << 64);
Expand All @@ -174,7 +180,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
"0x0000000000003FFF8000000000000000 = "
"(S: 0, E: 0x3FFF, I: 1, M: 0x00000000000000000000000000000000)");

FPBits<long double> negone(-1.0l);
LongDoubleBits negone(-1.0l);
EXPECT_EQ(negone.get_sign(), true);
EXPECT_EQ(negone.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(negone.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -185,7 +191,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
"0x000000000000BFFF8000000000000000 = "
"(S: 1, E: 0x3FFF, I: 1, M: 0x00000000000000000000000000000000)");

FPBits<long double> num(1.125l);
LongDoubleBits num(1.125l);
EXPECT_EQ(num.get_sign(), false);
EXPECT_EQ(num.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(num.get_mantissa(), static_cast<UInt128>(0x1) << 60);
Expand All @@ -195,7 +201,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
"0x0000000000003FFF9000000000000000 = "
"(S: 0, E: 0x3FFF, I: 1, M: 0x00000000000000001000000000000000)");

FPBits<long double> negnum(-1.125l);
LongDoubleBits negnum(-1.125l);
EXPECT_EQ(negnum.get_sign(), true);
EXPECT_EQ(negnum.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(negnum.get_mantissa(), static_cast<UInt128>(0x1) << 60);
Expand All @@ -210,16 +216,19 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
#if defined(LONG_DOUBLE_IS_DOUBLE)
return; // The tests for the "double" type cover for this case.
#else
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<long double>::inf()).c_str(),
"(+Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(FPBits<long double>::neg_inf()).c_str(),
"(-Infinity)");
EXPECT_STREQ(LIBC_NAMESPACE::str(
FPBits<long double>(FPBits<long double>::build_nan(1)))
.c_str(),
"(NaN)");
using LongDoubleBits = FPBits<long double>;

EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::inf())).c_str(),
"(+Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::neg_inf())).c_str(),
"(-Infinity)");
EXPECT_STREQ(
LIBC_NAMESPACE::str(LongDoubleBits(LongDoubleBits::build_nan(1))).c_str(),
"(NaN)");

FPBits<long double> zero(0.0l);
LongDoubleBits zero(0.0l);
EXPECT_EQ(zero.get_sign(), false);
EXPECT_EQ(zero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(zero.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -229,7 +238,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
"0x00000000000000000000000000000000 = "
"(S: 0, E: 0x0000, M: 0x00000000000000000000000000000000)");

FPBits<long double> negzero(-0.0l);
LongDoubleBits negzero(-0.0l);
EXPECT_EQ(negzero.get_sign(), true);
EXPECT_EQ(negzero.get_unbiased_exponent(), static_cast<uint16_t>(0x0000));
EXPECT_EQ(negzero.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -239,7 +248,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
"0x80000000000000000000000000000000 = "
"(S: 1, E: 0x0000, M: 0x00000000000000000000000000000000)");

FPBits<long double> one(1.0l);
LongDoubleBits one(1.0l);
EXPECT_EQ(one.get_sign(), false);
EXPECT_EQ(one.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(one.get_mantissa(), static_cast<UInt128>(0x0000000000000000) << 64);
Expand All @@ -248,7 +257,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
"0x3FFF0000000000000000000000000000 = "
"(S: 0, E: 0x3FFF, M: 0x00000000000000000000000000000000)");

FPBits<long double> negone(-1.0l);
LongDoubleBits negone(-1.0l);
EXPECT_EQ(negone.get_sign(), true);
EXPECT_EQ(negone.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(negone.get_mantissa(), static_cast<UInt128>(0x0000000000000000)
Expand All @@ -258,7 +267,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
"0xBFFF0000000000000000000000000000 = "
"(S: 1, E: 0x3FFF, M: 0x00000000000000000000000000000000)");

FPBits<long double> num(1.125l);
LongDoubleBits num(1.125l);
EXPECT_EQ(num.get_sign(), false);
EXPECT_EQ(num.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(num.get_mantissa(), static_cast<UInt128>(0x2) << 108);
Expand All @@ -267,7 +276,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) {
"0x3FFF2000000000000000000000000000 = "
"(S: 0, E: 0x3FFF, M: 0x00002000000000000000000000000000)");

FPBits<long double> negnum(-1.125l);
LongDoubleBits negnum(-1.125l);
EXPECT_EQ(negnum.get_sign(), true);
EXPECT_EQ(negnum.get_unbiased_exponent(), static_cast<uint16_t>(0x3FFF));
EXPECT_EQ(negnum.get_mantissa(), static_cast<UInt128>(0x2) << 108);
Expand Down
4 changes: 0 additions & 4 deletions libc/test/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1462,8 +1462,6 @@ add_fp_unittest(
libc.src.math.fmodf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.nearest_integer_operations
# Requires C++ limits.
UNIT_TEST_ONLY
)

add_fp_unittest(
Expand All @@ -1480,8 +1478,6 @@ add_fp_unittest(
libc.src.math.fmod
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.nearest_integer_operations
# Requires C++ limits.
UNIT_TEST_ONLY
)

add_fp_unittest(
Expand Down
327 changes: 152 additions & 175 deletions libc/test/src/math/FModTest.h

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,6 @@ add_fp_unittest(
libc.src.math.fmodf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.nearest_integer_operations
# Requires C++ limits.
UNIT_TEST_ONLY
)

add_fp_unittest(
Expand All @@ -1365,8 +1363,6 @@ add_fp_unittest(
libc.src.math.fmod
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.nearest_integer_operations
# Requires C++ limits.
UNIT_TEST_ONLY
)

add_fp_unittest(
Expand Down
327 changes: 152 additions & 175 deletions libc/test/src/math/smoke/FModTest.h

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions libc/test/src/stdio/sprintf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ TEST(LlvmLibcSPrintfTest, OctConv) {

TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) {
ForceRoundingMode r(RoundingMode::Nearest);
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf().get_val();
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf();
double nan = LIBC_NAMESPACE::fputil::FPBits<double>::build_nan(1);
written = LIBC_NAMESPACE::sprintf(buff, "%a", 1.0);
ASSERT_STREQ_LEN(written, buff, "0x1p+0");
Expand Down Expand Up @@ -950,10 +950,9 @@ TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) {

TEST_F(LlvmLibcSPrintfTest, FloatDecimalConv) {
ForceRoundingMode r(RoundingMode::Nearest);
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf().get_val();
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf();
double nan = LIBC_NAMESPACE::fputil::FPBits<double>::build_nan(1);
long double ld_inf =
LIBC_NAMESPACE::fputil::FPBits<long double>::inf().get_val();
long double ld_inf = LIBC_NAMESPACE::fputil::FPBits<long double>::inf();
long double ld_nan =
LIBC_NAMESPACE::fputil::FPBits<long double>::build_nan(1);

Expand Down Expand Up @@ -1791,7 +1790,7 @@ TEST_F(LlvmLibcSPrintfTest, FloatDecimalConv) {

TEST_F(LlvmLibcSPrintfTest, FloatExponentConv) {
ForceRoundingMode r(RoundingMode::Nearest);
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf().get_val();
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf();
double nan = LIBC_NAMESPACE::fputil::FPBits<double>::build_nan(1);

written = LIBC_NAMESPACE::sprintf(buff, "%e", 1.0);
Expand Down Expand Up @@ -2423,7 +2422,7 @@ TEST_F(LlvmLibcSPrintfTest, FloatExponentConv) {

TEST_F(LlvmLibcSPrintfTest, FloatAutoConv) {
ForceRoundingMode r(RoundingMode::Nearest);
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf().get_val();
double inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf();
double nan = LIBC_NAMESPACE::fputil::FPBits<double>::build_nan(1);

written = LIBC_NAMESPACE::sprintf(buff, "%g", 1.0);
Expand Down
8 changes: 4 additions & 4 deletions libc/test/src/stdio/sscanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ TEST(LlvmLibcSScanfTest, FloatConvSimple) {
int ret_val;
float result = 0;

float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf().get_val();
float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf();
float nan = LIBC_NAMESPACE::fputil::FPBits<float>::build_nan(1);

ret_val = LIBC_NAMESPACE::sscanf("123", "%f", &result);
Expand Down Expand Up @@ -295,7 +295,7 @@ TEST(LlvmLibcSScanfTest, FloatConvLengthModifier) {
double d_result = 0;
long double ld_result = 0;

double d_inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf().get_val();
double d_inf = LIBC_NAMESPACE::fputil::FPBits<double>::inf();
long double ld_nan =
LIBC_NAMESPACE::fputil::FPBits<long double>::build_nan(1);

Expand Down Expand Up @@ -392,7 +392,7 @@ TEST(LlvmLibcSScanfTest, FloatConvComplexParsing) {
int ret_val;
float result = 0;

float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf().get_val();
float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf();
float nan = LIBC_NAMESPACE::fputil::FPBits<float>::build_nan(1);

ret_val = LIBC_NAMESPACE::sscanf("0x1.0e3", "%f", &result);
Expand Down Expand Up @@ -464,7 +464,7 @@ TEST(LlvmLibcSScanfTest, FloatConvMaxWidth) {
int ret_val;
float result = 0;

float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf().get_val();
float inf = LIBC_NAMESPACE::fputil::FPBits<float>::inf();

ret_val = LIBC_NAMESPACE::sscanf("123", "%3f", &result);
EXPECT_EQ(ret_val, 1);
Expand Down