4 changes: 2 additions & 2 deletions libc/src/math/generic/range_reduction_fma.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
// least 2^6.
fputil::FPBits<double> prod_hi(x * THIRTYTWO_OVER_PI[0]);
prod_hi.bits &= (x_exp < 55) ? (~0xfffULL) : (~0ULL); // |x| < 2^55
double k_hi = fputil::nearest_integer(static_cast<double>(prod_hi));
double k_hi = fputil::nearest_integer(prod_hi.get_val());
double truncated_prod = fputil::fma(x, THIRTYTWO_OVER_PI[0], -k_hi);
double prod_lo = fputil::fma(x, THIRTYTWO_OVER_PI[1], truncated_prod);
double k_lo = fputil::nearest_integer(prod_lo);
Expand All @@ -71,7 +71,7 @@ LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
// least 64.
fputil::FPBits<double> prod_hi(x * THIRTYTWO_OVER_PI[1]);
prod_hi.bits &= (x_exp < 110) ? (~0xfffULL) : (~0ULL); // |x| < 2^110
double k_hi = fputil::nearest_integer(static_cast<double>(prod_hi));
double k_hi = fputil::nearest_integer(prod_hi.get_val());
double truncated_prod = fputil::fma(x, THIRTYTWO_OVER_PI[1], -k_hi);
double prod_lo = fputil::fma(x, THIRTYTWO_OVER_PI[2], truncated_prod);
double k_lo = fputil::nearest_integer(prod_lo);
Expand Down
6 changes: 3 additions & 3 deletions libc/src/stdio/printf_core/float_dec_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ LIBC_INLINE int convert_float_decimal_typed(Writer *writer,

PaddingWriter padding_writer(to_conv, sign_char);
FloatWriter float_writer(writer, has_decimal_point, padding_writer);
FloatToString<T> float_converter(static_cast<T>(float_bits));
FloatToString<T> float_converter(float_bits.get_val());

const size_t positive_blocks = float_converter.get_positive_blocks();

Expand Down Expand Up @@ -608,7 +608,7 @@ LIBC_INLINE int convert_float_dec_exp_typed(Writer *writer,

PaddingWriter padding_writer(to_conv, sign_char);
FloatWriter float_writer(writer, has_decimal_point, padding_writer);
FloatToString<T> float_converter(static_cast<T>(float_bits));
FloatToString<T> float_converter(float_bits.get_val());

size_t digits_written = 0;
int final_exponent = 0;
Expand Down Expand Up @@ -767,7 +767,7 @@ LIBC_INLINE int convert_float_dec_auto_typed(Writer *writer,
// it has style E, so here we calculate the precision we'll use in that case.
const unsigned int exp_precision = init_precision - 1;

FloatToString<T> float_converter(static_cast<T>(float_bits));
FloatToString<T> float_converter(float_bits.get_val());

// Here we would subtract 1 to account for the fact that block 0 counts as a
// positive block, but the loop below accounts for this by starting with
Expand Down
40 changes: 20 additions & 20 deletions libc/test/UnitTest/FPMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ template <typename T> struct FPTest : public Test {
using Sign = LIBC_NAMESPACE::fputil::Sign;
static constexpr StorageType STORAGE_MAX =
LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max();
static constexpr T zero = T(FPBits::zero(Sign::POS));
static constexpr T neg_zero = T(FPBits::zero(Sign::NEG));
static constexpr T aNaN = T(FPBits::build_quiet_nan());
static constexpr T sNaN = T(FPBits::build_nan(Sign::POS, 1));
static constexpr T inf = T(FPBits::inf(Sign::POS));
static constexpr T neg_inf = T(FPBits::inf(Sign::NEG));
static constexpr T min_normal = T(FPBits::min_normal());
static constexpr T max_normal = T(FPBits::max_normal());
static constexpr T min_denormal = T(FPBits::min_subnormal());
static constexpr T max_denormal = T(FPBits::max_subnormal());
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 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();
static constexpr T max_normal = FPBits::max_normal().get_val();
static constexpr T min_denormal = FPBits::min_subnormal().get_val();
static constexpr T max_denormal = FPBits::max_subnormal().get_val();

static constexpr int N_ROUNDING_MODES = 4;
static constexpr fputil::testing::RoundingMode ROUNDING_MODES[4] = {
Expand All @@ -95,16 +95,16 @@ template <typename T> struct FPTest : public Test {
using Sign = LIBC_NAMESPACE::fputil::Sign; \
static constexpr StorageType STORAGE_MAX = \
LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max(); \
const T zero = T(FPBits::zero(Sign::POS)); \
const T neg_zero = T(FPBits::zero(Sign::NEG)); \
const T aNaN = T(FPBits::build_quiet_nan()); \
const T sNaN = T(FPBits::build_nan(Sign::POS, 1)); \
const T inf = T(FPBits::inf(Sign::POS)); \
const T neg_inf = T(FPBits::inf(Sign::NEG)); \
const T min_normal = T(FPBits::min_normal()); \
const T max_normal = T(FPBits::max_normal()); \
const T min_denormal = T(FPBits::min_subnormal()); \
const T max_denormal = T(FPBits::max_subnormal());
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 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(); \
const T max_normal = FPBits::max_normal().get_val(); \
const T min_denormal = FPBits::min_subnormal().get_val(); \
const T max_denormal = FPBits::max_subnormal().get_val();

#define EXPECT_FP_EQ(expected, actual) \
EXPECT_THAT(actual, LIBC_NAMESPACE::testing::getMatcher< \
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/CeilTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename T> class CeilTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/CopySignTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CopySignTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FAbsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template <typename T> class FAbsTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, func(x), 0.0);
Expand Down
12 changes: 6 additions & 6 deletions libc/test/src/math/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

void test_na_n_arg(FuncPtr func) {
EXPECT_FP_EQ(nan, func(nan, inf));
Expand Down Expand Up @@ -66,7 +66,7 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template <typename T> class FMaxTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template <typename T> class FMinTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FloorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename T> class FloorTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down
28 changes: 14 additions & 14 deletions libc/test/src/math/FmaTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T min_subnormal = T(FPBits::min_subnormal(Sign::POS));
const T min_normal = T(FPBits::min_normal(Sign::POS));
const T max_normal = T(FPBits::max_normal(Sign::POS));
const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T min_subnormal = FPBits::min_subnormal(Sign::POS).get_val();
const T min_normal = FPBits::min_normal(Sign::POS).get_val();
const T max_normal = FPBits::max_normal(Sign::POS).get_val();
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType MAX_NORMAL = FPBits::max_normal().uintval();
static constexpr StorageType MIN_NORMAL = FPBits::min_normal().uintval();
Expand Down Expand Up @@ -63,9 +63,9 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {

// Test underflow rounding up.
EXPECT_FP_EQ(func(T(0.5), min_subnormal, min_subnormal),
T(FPBits(StorageType(2))));
FPBits(StorageType(2)).get_val());
// Test underflow rounding down.
T v = T(FPBits(MIN_NORMAL + StorageType(1)));
T v = FPBits(MIN_NORMAL + StorageType(1)).get_val();
EXPECT_FP_EQ(func(T(1) / T(MIN_NORMAL << 1), v, min_normal), v);
// Test overflow.
T z = max_normal;
Expand All @@ -80,8 +80,8 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType v = MIN_SUBNORMAL, w = MAX_SUBNORMAL;
v <= MAX_SUBNORMAL && w >= MIN_SUBNORMAL; v += STEP, w -= STEP) {
T x = T(FPBits(get_random_bit_pattern())), y = T(FPBits(v)),
z = T(FPBits(w));
T x = FPBits(get_random_bit_pattern()).get_val(), y = FPBits(v).get_val(),
z = FPBits(w).get_val();
mpfr::TernaryInput<T> input{x, y, z};
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Fma, input, func(x, y, z),
0.5);
Expand All @@ -93,8 +93,8 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType v = MIN_NORMAL, w = MAX_NORMAL;
v <= MAX_NORMAL && w >= MIN_NORMAL; v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w)),
z = T(FPBits(get_random_bit_pattern()));
T x = FPBits(v).get_val(), y = FPBits(w).get_val(),
z = FPBits(get_random_bit_pattern()).get_val();
mpfr::TernaryInput<T> input{x, y, z};
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Fma, input, func(x, y, z),
0.5);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FrexpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = static_cast<T>(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0l)
continue;

Expand Down
22 changes: 11 additions & 11 deletions libc/test/src/math/HypotTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using Sign = LIBC_NAMESPACE::fputil::Sign;
using StorageType = typename FPBits::StorageType;
const T nan = T(FPBits::build_quiet_nan());
const T inf = T(FPBits::inf());
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero());
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T max_normal = T(FPBits::max_normal());
const T min_normal = T(FPBits::min_normal());
const T max_subnormal = T(FPBits::max_subnormal());
const T min_subnormal = T(FPBits::min_subnormal());
const T nan = FPBits::build_quiet_nan().get_val();
const T inf = FPBits::inf().get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero().get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T max_normal = FPBits::max_normal().get_val();
const T min_normal = FPBits::min_normal().get_val();
const T max_subnormal = FPBits::max_subnormal().get_val();
const T min_subnormal = FPBits::min_subnormal().get_val();

static constexpr StorageType MAX_NORMAL = FPBits::max_normal().uintval();
static constexpr StorageType MIN_NORMAL = FPBits::min_normal().uintval();
Expand Down Expand Up @@ -74,7 +74,7 @@ class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
for (int signs = 0; signs < 4; ++signs) {
for (StorageType v = MIN_SUBNORMAL, w = max_value;
v <= max_value && w >= MIN_SUBNORMAL; v += step, w -= step) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (signs % 2 == 1) {
x = -x;
}
Expand All @@ -96,7 +96,7 @@ class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
for (int signs = 0; signs < 4; ++signs) {
for (StorageType v = MIN_NORMAL, w = MAX_NORMAL;
v <= MAX_NORMAL && w >= MIN_NORMAL; v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (signs % 2 == 1) {
x = -x;
}
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/math/ILogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
void test_special_numbers(typename ILogbFunc<T>::Func func) {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using Sign = LIBC_NAMESPACE::fputil::Sign;
EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero(Sign::POS))));
EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero(Sign::NEG))));
EXPECT_EQ(FP_ILOGBNAN, func(T(FPBits::build_quiet_nan())));
EXPECT_EQ(INT_MAX, func(T(FPBits::inf(Sign::POS))));
EXPECT_EQ(INT_MAX, func(T(FPBits::inf(Sign::NEG))));
EXPECT_EQ(FP_ILOGB0, func(FPBits::zero(Sign::POS).get_val()));
EXPECT_EQ(FP_ILOGB0, func(FPBits::zero(Sign::NEG).get_val()));
EXPECT_EQ(FP_ILOGBNAN, func(FPBits::build_quiet_nan().get_val()));
EXPECT_EQ(INT_MAX, func(FPBits::inf(Sign::POS).get_val()));
EXPECT_EQ(INT_MAX, func(FPBits::inf(Sign::NEG).get_val()));
}

template <typename T>
Expand Down Expand Up @@ -81,7 +81,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 10'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType v = MIN_SUBNORMAL; v <= MAX_SUBNORMAL; v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0)
continue;

Expand All @@ -100,7 +100,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 10'001;
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType v = MIN_NORMAL; v <= MAX_NORMAL; v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0)
continue;

Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/LdExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

// A normalized mantissa to be used with tests.
static constexpr StorageType MANTISSA = NormalFloat::ONE + 0x1234;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/LogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ template <typename T> class LogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = static_cast<T>(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0l)
continue;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/ModfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == T(0.0))
continue;

Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

const StorageType min_subnormal = FPBits::min_subnormal().uintval();
const StorageType max_subnormal = FPBits::max_subnormal().uintval();
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/math/RIntTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType MIN_SUBNORMAL =
FPBits::min_subnormal().uintval();
Expand Down Expand Up @@ -104,7 +104,7 @@ class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType i = MIN_SUBNORMAL; i <= MAX_SUBNORMAL; i += STEP) {
T x = T(FPBits(i));
T x = FPBits(i).get_val();
for (int mode : ROUNDING_MODES) {
LIBC_NAMESPACE::fputil::set_round(mode);
mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode);
Expand All @@ -117,7 +117,7 @@ class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType i = MIN_NORMAL; i <= MAX_NORMAL; i += STEP) {
T x = T(FPBits(i));
T x = FPBits(i).get_val();
// In normal range on x86 platforms, the long double implicit 1 bit can be
// zero making the numbers NaN. We will skip them.
if (isnan(x)) {
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/math/RemQuoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType MIN_SUBNORMAL =
FPBits::min_subnormal().uintval();
Expand Down Expand Up @@ -107,7 +107,7 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType v = MIN_SUBNORMAL, w = MAX_SUBNORMAL;
v <= MAX_SUBNORMAL && w >= MIN_SUBNORMAL; v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
mpfr::BinaryOutput<T> result;
mpfr::BinaryInput<T> input{x, y};
result.f = func(x, y, &result.i);
Expand All @@ -120,7 +120,7 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType v = MIN_NORMAL, w = MAX_NORMAL;
v <= MAX_NORMAL && w >= MIN_NORMAL; v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
mpfr::BinaryOutput<T> result;
mpfr::BinaryInput<T> input{x, y};
result.f = func(x, y, &result.i);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/RoundTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down
18 changes: 9 additions & 9 deletions libc/test/src/math/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const F zero = F(FPBits::zero());
const F neg_zero = F(FPBits::zero(Sign::NEG));
const F inf = F(FPBits::inf());
const F neg_inf = F(FPBits::inf(Sign::NEG));
const F nan = F(FPBits::build_quiet_nan());
const F zero = FPBits::zero().get_val();
const F neg_zero = FPBits::zero(Sign::NEG).get_val();
const F inf = FPBits::inf().get_val();
const F neg_inf = FPBits::inf(Sign::NEG).get_val();
const F nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType MAX_NORMAL = FPBits::max_normal().uintval();
static constexpr StorageType MIN_NORMAL = FPBits::min_normal().uintval();
Expand Down Expand Up @@ -139,7 +139,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
bits.set_sign(Sign::NEG);
bits.set_mantissa(0);

F x = F(bits);
F x = bits.get_val();
long mpfr_result;
bool erangeflag = mpfr::round_to_long(x, mpfr_result);
ASSERT_FALSE(erangeflag);
Expand Down Expand Up @@ -203,7 +203,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
bits.set_sign(Sign::NEG);
bits.set_mantissa(FPBits::FRACTION_MASK);

F x = F(bits);
F x = bits.get_val();
if (TestModes) {
for (int m : ROUNDING_MODES) {
LIBC_NAMESPACE::fputil::set_round(m);
Expand All @@ -225,7 +225,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 1'000'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType i = MIN_SUBNORMAL; i <= MAX_SUBNORMAL; i += STEP) {
F x = F(FPBits(i));
F x = FPBits(i).get_val();
if (x == F(0.0))
continue;
// All subnormal numbers should round to zero.
Expand Down Expand Up @@ -267,7 +267,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 1'000'001;
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType i = MIN_NORMAL; i <= MAX_NORMAL; i += STEP) {
F x = F(FPBits(i));
F x = FPBits(i).get_val();
// In normal range on x86 platforms, the long double implicit 1 bit can be
// zero making the numbers NaN. We will skip them.
if (isnan(x)) {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/SqrtTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
for (StorageType mant = 1; mant < HIDDEN_BIT; mant <<= 1) {
FPBits denormal(T(0.0));
denormal.set_mantissa(mant);
T x = T(denormal);
T x = denormal.get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sqrt, x, func(x), 0.5);
}

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/TruncTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename T> class TruncTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/acosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST_F(LlvmLibcAcosfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
Expand All @@ -74,7 +74,7 @@ TEST_F(LlvmLibcAcosfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
LIBC_NAMESPACE::acosf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, -x,
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/acoshf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST_F(LlvmLibcAcoshfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
Expand All @@ -70,7 +70,7 @@ TEST_F(LlvmLibcAcoshfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
LIBC_NAMESPACE::acoshf(x), 0.5);
}
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/asinf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST_F(LlvmLibcAsinfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x,
Expand All @@ -70,7 +70,7 @@ TEST_F(LlvmLibcAsinfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x,
LIBC_NAMESPACE::asinf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, -x,
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/asinhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST_F(LlvmLibcAsinhfTest, InFloatRange) {
constexpr uint32_t COUNT = 1'001;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
Expand All @@ -71,7 +71,7 @@ TEST_F(LlvmLibcAsinhfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
LIBC_NAMESPACE::asinhf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, -x,
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/atanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TEST_F(LlvmLibcAtanfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
const uint32_t STEP = FPBits(inf).uintval() / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x,
LIBC_NAMESPACE::atanf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, -x,
Expand All @@ -56,7 +56,7 @@ TEST_F(LlvmLibcAtanfTest, SpecialValues) {
uint32_t val_arr[] = {0x3d8d6b23U, 0x3feefcfbU, 0xbd8d6b23U,
0xbfeefcfbU, 0x7F800000U, 0xFF800000U};
for (uint32_t v : val_arr) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x,
LIBC_NAMESPACE::atanf(x), 0.5);
}
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/math/atanhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST_F(LlvmLibcAtanhfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
const uint32_t STEP = FPBits(1.0f).uintval() / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
ASSERT_MPFR_MATCH(mpfr::Operation::Atanh, x, LIBC_NAMESPACE::atanhf(x),
0.5);
ASSERT_MPFR_MATCH(mpfr::Operation::Atanh, -x, LIBC_NAMESPACE::atanhf(-x),
Expand All @@ -98,12 +98,12 @@ TEST_F(LlvmLibcAtanhfTest, InFloatRange) {

// For small values, atanh(x) is x.
TEST_F(LlvmLibcAtanhfTest, SmallValues) {
float x = float(FPBits(uint32_t(0x17800000)));
float x = FPBits(uint32_t(0x17800000)).get_val();
float result = LIBC_NAMESPACE::atanhf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Atanh, x, result, 0.5);
EXPECT_FP_EQ(x, result);

x = float(FPBits(uint32_t(0x00400000)));
x = FPBits(uint32_t(0x00400000)).get_val();
result = LIBC_NAMESPACE::atanhf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Atanh, x, result, 0.5);
EXPECT_FP_EQ(x, result);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/cos_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TEST_F(LlvmLibcCosTest, Range) {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
double x = double(FPBits(v));
double x = FPBits(v).get_val();
// TODO: Expand the range of testing after range reduction is implemented.
if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi)
continue;
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/math/cosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST_F(LlvmLibcCosfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
Expand Down Expand Up @@ -102,7 +102,7 @@ TEST_F(LlvmLibcCosfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
LIBC_NAMESPACE::cosf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, -x,
Expand All @@ -114,7 +114,7 @@ TEST_F(LlvmLibcCosfTest, SpecificBitPatterns) {
// returns values furthest beyond its nominal upper bound of pi/4.
TEST_F(LlvmLibcCosfTest, SDCOMP_26094) {
for (uint32_t v : SDCOMP26094_VALUES) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x), 0.5);
}
}
12 changes: 6 additions & 6 deletions libc/test/src/math/coshf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,36 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
TEST_F(LlvmLibcCoshfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

TEST_F(LlvmLibcCoshfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH(mpfr::Operation::Cosh, x, LIBC_NAMESPACE::coshf(x), 0.5);
}
}

TEST_F(LlvmLibcCoshfTest, SmallValues) {
float x = float(FPBits(0x17800000U));
float x = FPBits(0x17800000U).get_val();
float result = LIBC_NAMESPACE::coshf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Cosh, x, result, 0.5);
EXPECT_FP_EQ(1.0f, result);

x = float(FPBits(0x0040000U));
x = FPBits(0x0040000U).get_val();
result = LIBC_NAMESPACE::coshf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Cosh, x, result, 0.5);
EXPECT_FP_EQ(1.0f, result);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/erff_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(LlvmLibcErffTest, TrickyInputs) {
0x4004'1e6aU, // |x| = 0x1.083cd4p+1f
};
for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Erf, x,
LIBC_NAMESPACE::erff(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Erf, -x,
Expand Down
7 changes: 3 additions & 4 deletions libc/test/src/math/exhaustive/exhaustive_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct UnaryOpChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
FPBits xbits(bits);
FloatType x = FloatType(xbits);
FloatType x = xbits.get_val();
bool correct =
TEST_MPFR_MATCH_ROUNDING_SILENTLY(Op, x, FUNC(x), 0.5, rounding);
failed += (!correct);
Expand Down Expand Up @@ -127,9 +127,8 @@ struct LlvmLibcExhaustiveMathTest
msg << "Test failed for " << std::dec << failed_in_range
<< " inputs in range: " << range_begin << " to " << range_end
<< " [0x" << std::hex << range_begin << ", 0x" << range_end
<< "), [" << std::hexfloat
<< static_cast<FloatType>(FPBits(range_begin)) << ", "
<< static_cast<FloatType>(FPBits(range_end)) << ")\n";
<< "), [" << std::hexfloat << FPBits(range_begin).get_val()
<< ", " << FPBits(range_end).get_val() << ")\n";
std::cerr << msg.str() << std::flush;

failed.fetch_add(failed_in_range);
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/exhaustive/hypotf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ struct HypotfChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint32_t xbits = start;
uint64_t failed = 0;
do {
float x = float(FPBits(xbits));
float x = FPBits(xbits).get_val();
uint32_t ybits = Y_START;
do {
float y = float(FPBits(ybits));
float y = FPBits(ybits).get_val();
bool correct = TEST_FP_EQ(LIBC_NAMESPACE::fputil::hypot(x, y),
LIBC_NAMESPACE::hypotf(x, y));
// Using MPFR will be much slower.
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/exhaustive/sincosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct SincosfChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
FPBits xbits(bits);
FloatType x = FloatType(xbits);
FloatType x = xbits.get_val();
FloatType sinx, cosx;
LIBC_NAMESPACE::sincosf(x, &sinx, &cosx);

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/exp10_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TEST_F(LlvmLibcExp10Test, TrickyInputs) {
0x4037000000000000, // x = 23
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10(x), 0.5);
}
Expand Down
17 changes: 9 additions & 8 deletions libc/test/src/math/exp10f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,31 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
TEST_F(LlvmLibcExp10fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x43000000U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x43000000U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x43000001U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x43000001U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

TEST_F(LlvmLibcExp10fTest, Underflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, LIBC_NAMESPACE::exp10f(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
0.0f, LIBC_NAMESPACE::exp10f(FPBits(0xff7fffffU).get_val()),
FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

float x = float(FPBits(0xc2cffff8U));
float x = FPBits(0xc2cffff8U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10f(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);

x = float(FPBits(0xc2d00008U));
x = FPBits(0xc2d00008U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10f(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);
Expand Down Expand Up @@ -97,7 +98,7 @@ TEST_F(LlvmLibcExp10fTest, TrickyInputs) {
};
for (int i = 0; i < N; ++i) {
libc_errno = 0;
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10f(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, -x,
Expand All @@ -109,7 +110,7 @@ TEST_F(LlvmLibcExp10fTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/exp2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST_F(LlvmLibcExp2Test, TrickyInputs) {
0xbc971547652b82fe, // x=-0x1.71547652b82fep-54
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
LIBC_NAMESPACE::exp2(x), 0.5);
}
Expand Down
18 changes: 9 additions & 9 deletions libc/test/src/math/exp2f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ TEST_F(LlvmLibcExp2fTest, SpecialNumbers) {
TEST_F(LlvmLibcExp2fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x43000000U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x43000000U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x43000001U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x43000001U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

Expand All @@ -73,7 +73,7 @@ TEST_F(LlvmLibcExp2fTest, TrickyInputs) {
};
for (int i = 0; i < N; ++i) {
libc_errno = 0;
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
LIBC_NAMESPACE::exp2f(x), 0.5);
EXPECT_MATH_ERRNO(0);
Expand All @@ -83,20 +83,20 @@ TEST_F(LlvmLibcExp2fTest, TrickyInputs) {
TEST_F(LlvmLibcExp2fTest, Underflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, LIBC_NAMESPACE::exp2f(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
0.0f, LIBC_NAMESPACE::exp2f(FPBits(0xff7fffffU).get_val()), FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

float x = float(FPBits(0xc3158000U));
float x = FPBits(0xc3158000U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
LIBC_NAMESPACE::exp2f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc3160000U));
x = FPBits(0xc3160000U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
LIBC_NAMESPACE::exp2f(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);

x = float(FPBits(0xc3165432U));
x = FPBits(0xc3165432U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
LIBC_NAMESPACE::exp2f(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);
Expand All @@ -106,7 +106,7 @@ TEST_F(LlvmLibcExp2fTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/exp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TEST_F(LlvmLibcExpTest, TrickyInputs) {
0xc0867a172ceb0990, // x=-0x1.67a172ceb099p+9
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::exp(x), 0.5);
}
Expand Down
24 changes: 12 additions & 12 deletions libc/test/src/math/expf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@ TEST_F(LlvmLibcExpfTest, SpecialNumbers) {
TEST_F(LlvmLibcExpfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

TEST_F(LlvmLibcExpfTest, Underflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, LIBC_NAMESPACE::expf(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
0.0f, LIBC_NAMESPACE::expf(FPBits(0xff7fffffU).get_val()), FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

float x = float(FPBits(0xc2cffff8U));
float x = FPBits(0xc2cffff8U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);

x = float(FPBits(0xc2d00008U));
x = FPBits(0xc2d00008U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(ERANGE);
Expand All @@ -77,27 +77,27 @@ TEST_F(LlvmLibcExpfTest, Borderline) {
float x;

libc_errno = 0;
x = float(FPBits(0x42affff8U));
x = FPBits(0x42affff8U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0x42b00008U));
x = FPBits(0x42b00008U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc2affff8U));
x = FPBits(0xc2affff8U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc2b00008U));
x = FPBits(0xc2b00008U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc236bd8cU));
x = FPBits(0xc236bd8cU).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
LIBC_NAMESPACE::expf(x), 0.5);
EXPECT_MATH_ERRNO(0);
Expand All @@ -107,7 +107,7 @@ TEST_F(LlvmLibcExpfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/expm1_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TEST_F(LlvmLibcExpm1Test, TrickyInputs) {
0xc042b708872320dd, // x=-0x1.2b708872320ddp+5
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1(x), 0.5);
}
Expand Down
30 changes: 15 additions & 15 deletions libc/test/src/math/expm1f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) {
TEST_F(LlvmLibcExpm1fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

TEST_F(LlvmLibcExpm1fTest, Underflow) {
libc_errno = 0;
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::expm1f(float(FPBits(0xff7fffffU))));
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::expm1f(FPBits(0xff7fffffU).get_val()));

float x = float(FPBits(0xc2cffff8U));
float x = FPBits(0xc2cffff8U).get_val();
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::expm1f(x));

x = float(FPBits(0xc2d00008U));
x = FPBits(0xc2d00008U).get_val();
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::expm1f(x));
}

Expand All @@ -71,42 +71,42 @@ TEST_F(LlvmLibcExpm1fTest, Borderline) {
float x;

libc_errno = 0;
x = float(FPBits(0x42affff8U));
x = FPBits(0x42affff8U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0x42b00008U));
x = FPBits(0x42b00008U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc2affff8U));
x = FPBits(0xc2affff8U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xc2b00008U));
x = FPBits(0xc2b00008U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0x3dc252ddU));
x = FPBits(0x3dc252ddU).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0x3e35bec5U));
x = FPBits(0x3e35bec5U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0x942ed494U));
x = FPBits(0x942ed494U).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);

x = float(FPBits(0xbdc1c6cbU));
x = FPBits(0xbdc1c6cbU).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
LIBC_NAMESPACE::expm1f(x), 0.5);
EXPECT_MATH_ERRNO(0);
Expand All @@ -116,7 +116,7 @@ TEST_F(LlvmLibcExpm1fTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/log10_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST_F(LlvmLibcLog10Test, TrickyInputs) {
0x30160580e7268a99, 0x5ca04103b7eaa345, 0x19ad77dc4a40093f,
0x0000449fb5c8a96e};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
LIBC_NAMESPACE::log10(x), 0.5);
}
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/log10f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST_F(LlvmLibcLog10fTest, TrickyInputs) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
LIBC_NAMESPACE::log10f(x), 0.5);
}
Expand All @@ -69,7 +69,7 @@ TEST_F(LlvmLibcLog10fTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
LIBC_NAMESPACE::log10f(x), 0.5);
}
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/log1p_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
0x5671e2f1628093e4, 0x73dac56e2bf1a951, 0x8001bc6879ea14c5,
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
LIBC_NAMESPACE::log1p(x), 0.5);
}
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/log1pf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST_F(LlvmLibcLog1pfTest, TrickyInputs) {
0xbf800000U, /*-1.0f*/
};
for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
LIBC_NAMESPACE::log1pf(x), 0.5);
}
Expand All @@ -73,7 +73,7 @@ TEST_F(LlvmLibcLog1pfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/log2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST_F(LlvmLibcLog2Test, TrickyInputs) {
0x3fefbfdaa448ed98,
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log2, x,
LIBC_NAMESPACE::log2(x), 0.5);
}
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/log2f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_F(LlvmLibcLog2fTest, TrickyInputs) {
0x3f80079bU, 0x3f81d0b5U, 0x3f82e602U, 0x3f83c98dU, 0x3f8cba39U};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log2, x,
LIBC_NAMESPACE::log2f(x), 0.5);
}
Expand All @@ -49,7 +49,7 @@ TEST_F(LlvmLibcLog2fTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
libc_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/log_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST_F(LlvmLibcLogTest, TrickyInputs) {
0x3fefbfdaa448ed98,
};
for (int i = 0; i < N; ++i) {
double x = double(FPBits(INPUTS[i]));
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
LIBC_NAMESPACE::log(x), 0.5);
}
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/math/logf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TEST_F(LlvmLibcLogfTest, TrickyInputs) {
0x7a17f30aU, /*0x1.2fe614p+117f*/
};
for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
LIBC_NAMESPACE::logf(x), 0.5);
}
Expand All @@ -81,7 +81,7 @@ TEST_F(LlvmLibcLogfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/sin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST_F(LlvmLibcSinTest, Range) {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
double x = double(FPBits(v));
double x = FPBits(v).get_val();
// TODO: Expand the range of testing after range reduction is implemented.
if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi)
continue;
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/math/sincosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TEST_F(LlvmLibcSinCosfTest, InFloatRange) {
constexpr uint32_t COUNT = 1'001;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits((v)));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

Expand Down Expand Up @@ -159,7 +159,7 @@ TEST_F(LlvmLibcSinCosfTest, SpecialValues) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_SINCOS_MATCH_ALL_ROUNDING(x);
EXPECT_SINCOS_MATCH_ALL_ROUNDING(-x);
}
Expand All @@ -169,7 +169,7 @@ TEST_F(LlvmLibcSinCosfTest, SpecialValues) {
// returns values furthest beyond its nominal upper bound of pi/4.
TEST_F(LlvmLibcSinCosfTest, SDCOMP_26094) {
for (uint32_t v : SDCOMP26094_VALUES) {
float x = float(FPBits((v)));
float x = FPBits(v).get_val();
EXPECT_SINCOS_MATCH_ALL_ROUNDING(x);
EXPECT_SINCOS_MATCH_ALL_ROUNDING(-x);
}
Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/sinf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST_F(LlvmLibcSinfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
Expand Down Expand Up @@ -97,7 +97,7 @@ TEST_F(LlvmLibcSinfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
LIBC_NAMESPACE::sinf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, -x,
Expand All @@ -107,11 +107,11 @@ TEST_F(LlvmLibcSinfTest, SpecificBitPatterns) {

// For small values, sin(x) is x.
TEST_F(LlvmLibcSinfTest, SmallValues) {
float x = float(FPBits(0x1780'0000U));
float x = FPBits(0x1780'0000U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
LIBC_NAMESPACE::sinf(x), 0.5);

x = float(FPBits(0x0040'0000U));
x = FPBits(0x0040'0000U).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
LIBC_NAMESPACE::sinf(x), 0.5);
}
Expand All @@ -120,7 +120,7 @@ TEST_F(LlvmLibcSinfTest, SmallValues) {
// returns values furthest beyond its nominal upper bound of pi/4.
TEST_F(LlvmLibcSinfTest, SDCOMP_26094) {
for (uint32_t v : SDCOMP26094_VALUES) {
float x = float(FPBits((v)));
float x = FPBits((v)).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
LIBC_NAMESPACE::sinf(x), 0.5);
}
Expand Down
16 changes: 8 additions & 8 deletions libc/test/src/math/sinhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST_F(LlvmLibcSinhfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH(mpfr::Operation::Sinh, x, LIBC_NAMESPACE::sinhf(x), 0.5);
Expand All @@ -54,12 +54,12 @@ TEST_F(LlvmLibcSinhfTest, InFloatRange) {

// For small values, sinh(x) is x.
TEST_F(LlvmLibcSinhfTest, SmallValues) {
float x = float(FPBits(uint32_t(0x17800000)));
float x = FPBits(uint32_t(0x17800000)).get_val();
float result = LIBC_NAMESPACE::sinhf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Sinh, x, result, 0.5);
EXPECT_FP_EQ(x, result);

x = float(FPBits(uint32_t(0x00400000)));
x = FPBits(uint32_t(0x00400000)).get_val();
result = LIBC_NAMESPACE::sinhf(x);
EXPECT_MPFR_MATCH(mpfr::Operation::Sinh, x, result, 0.5);
EXPECT_FP_EQ(x, result);
Expand All @@ -68,24 +68,24 @@ TEST_F(LlvmLibcSinhfTest, SmallValues) {
TEST_F(LlvmLibcSinhfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}

TEST_F(LlvmLibcSinhfTest, ExceptionalValues) {
float x = float(FPBits(uint32_t(0x3a12'85ffU)));
float x = FPBits(uint32_t(0x3a12'85ffU)).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
LIBC_NAMESPACE::sinhf(x), 0.5);

x = -float(FPBits(uint32_t(0x3a12'85ffU)));
x = -FPBits(uint32_t(0x3a12'85ffU)).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
LIBC_NAMESPACE::sinhf(x), 0.5);
}
12 changes: 6 additions & 6 deletions libc/test/src/math/smoke/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

void test_na_n_arg(FuncPtr func) {
EXPECT_FP_EQ(nan, func(nan, inf));
Expand Down Expand Up @@ -66,7 +66,7 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ template <typename T> class FMaxTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ template <typename T> class FMinTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
T x = T(FPBits(v)), y = T(FPBits(w));
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
if (isnan(x) || isinf(x))
continue;
if (isnan(y) || isinf(y))
Expand Down
24 changes: 12 additions & 12 deletions libc/test/src/math/smoke/FmaTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

public:
void test_special_numbers(Func func) {
Expand All @@ -39,16 +39,16 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
EXPECT_FP_EQ(func(inf, neg_inf, nan), nan);

// Test underflow rounding up.
EXPECT_FP_EQ(
func(T(0.5), T(FPBits::min_subnormal()), T(FPBits::min_subnormal())),
T(FPBits(StorageType(2))));
EXPECT_FP_EQ(func(T(0.5), FPBits::min_subnormal().get_val(),
FPBits::min_subnormal().get_val()),
FPBits(StorageType(2)).get_val());
// Test underflow rounding down.
StorageType MIN_NORMAL = FPBits::min_normal().uintval();
T v = T(FPBits(MIN_NORMAL + StorageType(1)));
EXPECT_FP_EQ(func(T(1) / T(MIN_NORMAL << 1), v, T(FPBits::min_normal())),
v);
T v = FPBits(MIN_NORMAL + StorageType(1)).get_val();
EXPECT_FP_EQ(
func(T(1) / T(MIN_NORMAL << 1), v, FPBits::min_normal().get_val()), v);
// Test overflow.
T z = T(FPBits::max_normal());
T z = FPBits::max_normal().get_val();
EXPECT_FP_EQ(func(T(1.75), z, -z), T(0.75) * z);
// Exact cancellation.
EXPECT_FP_EQ(func(T(3.0), T(5.0), -T(15.0)), T(0.0));
Expand Down
20 changes: 10 additions & 10 deletions libc/test/src/math/smoke/HypotTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;
const T nan = T(FPBits::build_quiet_nan());
const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));

const T max_normal = T(FPBits::max_normal());
const T min_normal = T(FPBits::min_normal());
const T max_subnormal = T(FPBits::max_subnormal());
const T min_subnormal = T(FPBits::min_subnormal());
const T nan = FPBits::build_quiet_nan().get_val();
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();

const T max_normal = FPBits::max_normal().get_val();
const T min_normal = FPBits::min_normal().get_val();
const T max_subnormal = FPBits::max_subnormal().get_val();
const T min_subnormal = FPBits::min_subnormal().get_val();

public:
void test_special_numbers(Func func) {
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/math/smoke/ILogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
void test_special_numbers(typename ILogbFunc<T>::Func func) {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using Sign = LIBC_NAMESPACE::fputil::Sign;
EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero(Sign::POS))));
EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero(Sign::NEG))));
EXPECT_EQ(FP_ILOGBNAN, func(T(FPBits::build_quiet_nan())));
EXPECT_EQ(INT_MAX, func(T(FPBits::inf(Sign::POS))));
EXPECT_EQ(INT_MAX, func(T(FPBits::inf(Sign::NEG))));
EXPECT_EQ(FP_ILOGB0, func(FPBits::zero(Sign::POS).get_val()));
EXPECT_EQ(FP_ILOGB0, func(FPBits::zero(Sign::NEG).get_val()));
EXPECT_EQ(FP_ILOGBNAN, func(FPBits::build_quiet_nan().get_val()));
EXPECT_EQ(INT_MAX, func(FPBits::inf(Sign::POS).get_val()));
EXPECT_EQ(INT_MAX, func(FPBits::inf(Sign::NEG).get_val()));
}

template <typename T>
Expand Down Expand Up @@ -81,7 +81,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 10'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType v = MIN_SUBNORMAL; v <= MAX_SUBNORMAL; v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0)
continue;

Expand All @@ -100,7 +100,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 10'001;
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
for (StorageType v = MIN_NORMAL; v <= MAX_NORMAL; v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0)
continue;

Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/LdExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

// A normalized mantissa to be used with tests.
static constexpr StorageType MANTISSA = NormalFloat::ONE + 0x1234;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/LogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ template <typename T> class LogbTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = static_cast<T>(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == 0.0l)
continue;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/ModfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = T(FPBits(v));
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x == T(0.0))
continue;

Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType min_subnormal =
FPBits::min_subnormal().uintval();
Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/NextTowardTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

const long double to_zero = ToFPBits::zero().get_val();
const long double to_neg_zero = ToFPBits::zero(Sign::NEG).get_val();
Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/RIntTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

public:
void testSpecialNumbers(RIntFunc func) {
Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/RemQuoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const T inf = T(FPBits::inf(Sign::POS));
const T neg_inf = T(FPBits::inf(Sign::NEG));
const T zero = T(FPBits::zero(Sign::POS));
const T neg_zero = T(FPBits::zero(Sign::NEG));
const T nan = T(FPBits::build_quiet_nan());
const T inf = FPBits::inf(Sign::POS).get_val();
const T neg_inf = FPBits::inf(Sign::NEG).get_val();
const T zero = FPBits::zero(Sign::POS).get_val();
const T neg_zero = FPBits::zero(Sign::NEG).get_val();
const T nan = FPBits::build_quiet_nan().get_val();

public:
typedef T (*RemQuoFunc)(T, T, int *);
Expand Down
12 changes: 6 additions & 6 deletions libc/test/src/math/smoke/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
using StorageType = typename FPBits::StorageType;
using Sign = LIBC_NAMESPACE::fputil::Sign;

const F zero = F(FPBits::zero(Sign::POS));
const F neg_zero = F(FPBits::zero(Sign::NEG));
const F inf = F(FPBits::inf(Sign::POS));
const F neg_inf = F(FPBits::inf(Sign::NEG));
const F nan = F(FPBits::build_quiet_nan());
const F zero = FPBits::zero(Sign::POS).get_val();
const F neg_zero = FPBits::zero(Sign::NEG).get_val();
const F inf = FPBits::inf(Sign::POS).get_val();
const F neg_inf = FPBits::inf(Sign::NEG).get_val();
const F nan = FPBits::build_quiet_nan().get_val();

static constexpr StorageType MAX_SUBNORMAL =
FPBits::max_subnormal().uintval();
Expand Down Expand Up @@ -119,7 +119,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
constexpr StorageType COUNT = 1'000'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
for (StorageType i = MIN_SUBNORMAL; i <= MAX_SUBNORMAL; i += STEP) {
F x = F(FPBits(i));
F x = FPBits(i).get_val();
if (x == F(0.0))
continue;
// All subnormal numbers should round to zero.
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/math/smoke/coshf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
TEST_F(LlvmLibcCoshfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::coshf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
6 changes: 3 additions & 3 deletions libc/test/src/math/smoke/exp10f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
TEST_F(LlvmLibcExp10fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x43000000U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x43000000U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(float(FPBits(0x43000001U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp10f(FPBits(0x43000001U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
6 changes: 3 additions & 3 deletions libc/test/src/math/smoke/exp2f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ TEST_F(LlvmLibcExp2fTest, SpecialNumbers) {
TEST_F(LlvmLibcExp2fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x43000000U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x43000000U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp2f(float(FPBits(0x43000001U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::exp2f(FPBits(0x43000001U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
6 changes: 3 additions & 3 deletions libc/test/src/math/smoke/expf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ TEST_F(LlvmLibcExpfTest, SpecialNumbers) {
TEST_F(LlvmLibcExpfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
6 changes: 3 additions & 3 deletions libc/test/src/math/smoke/expm1f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) {
TEST_F(LlvmLibcExpm1fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::expm1f(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::expm1f(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/sinhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ TEST_F(LlvmLibcSinhfTest, SpecialNumbers) {

// For small values, sinh(x) is x.
TEST_F(LlvmLibcSinhfTest, SmallValues) {
float x = float(FPBits(uint32_t(0x17800000)));
float x = FPBits(uint32_t(0x17800000)).get_val();
float result = LIBC_NAMESPACE::sinhf(x);
EXPECT_FP_EQ(x, result);

x = float(FPBits(uint32_t(0x00400000)));
x = FPBits(uint32_t(0x00400000)).get_val();
result = LIBC_NAMESPACE::sinhf(x);
EXPECT_FP_EQ(x, result);
}

TEST_F(LlvmLibcSinhfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x42cffff8U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x42cffff8U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::sinhf(float(FPBits(0x42d00008U))), FE_OVERFLOW);
inf, LIBC_NAMESPACE::sinhf(FPBits(0x42d00008U).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
}
2 changes: 1 addition & 1 deletion libc/test/src/math/tan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TEST_F(LlvmLibcTanTest, Range) {
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
double x = double(FPBits(v));
double x = FPBits(v).get_val();
// TODO: Expand the range of testing after range reduction is implemented.
if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi)
continue;
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/math/tanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST_F(LlvmLibcTanfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'000;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
Expand Down Expand Up @@ -115,7 +115,7 @@ TEST_F(LlvmLibcTanfTest, SpecificBitPatterns) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
LIBC_NAMESPACE::tanf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, -x,
Expand All @@ -127,7 +127,7 @@ TEST_F(LlvmLibcTanfTest, SpecificBitPatterns) {
// returns values furthest beyond its nominal upper bound of pi/4.
TEST_F(LlvmLibcTanfTest, SDCOMP_26094) {
for (uint32_t v : SDCOMP26094_VALUES) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
ASSERT_MPFR_MATCH(mpfr::Operation::Tan, x, LIBC_NAMESPACE::tanf(x), 0.5);
}
}
4 changes: 2 additions & 2 deletions libc/test/src/math/tanhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST_F(LlvmLibcTanhfTest, InFloatRange) {
constexpr uint32_t COUNT = 100'001;
constexpr uint32_t STEP = UINT32_MAX / COUNT;
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
float x = float(FPBits(v));
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x,
Expand All @@ -62,7 +62,7 @@ TEST_F(LlvmLibcTanhfTest, ExceptionalValues) {
};

for (int i = 0; i < N; ++i) {
float x = float(FPBits(INPUTS[i]));
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x,
LIBC_NAMESPACE::tanhf(x), 0.5);
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, -x,
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/stdlib/atof_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(LlvmLibcAToFTest, SimpleTest) {

libc_errno = 0;
EXPECT_THAT(LIBC_NAMESPACE::atof("123"),
Succeeds<double>(static_cast<double>(expected_fp)));
Succeeds<double>(expected_fp.get_val()));
}

TEST(LlvmLibcAToFTest, FailedParsingTest) {
Expand Down
5 changes: 2 additions & 3 deletions libc/test/src/stdlib/strtod_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ class LlvmLibcStrToDTest : public LIBC_NAMESPACE::testing::Test,
libc_errno = 0;
double result = LIBC_NAMESPACE::strtod(inputString, &str_end);
if (expectedErrno == 0)
EXPECT_THAT(result, Succeeds<double>(static_cast<double>(expected_fp)));
EXPECT_THAT(result, Succeeds<double>(expected_fp.get_val()));
else
EXPECT_THAT(result, Fails<double>(expectedErrno,
static_cast<double>(expected_fp)));
EXPECT_THAT(result, Fails<double>(expectedErrno, expected_fp.get_val()));
EXPECT_EQ(str_end - inputString, expectedStrLen);
}
};
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/stdlib/strtof_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LlvmLibcStrToFTest : public LIBC_NAMESPACE::testing::Test,
float result = LIBC_NAMESPACE::strtof(inputString, &str_end);

EXPECT_EQ(str_end - inputString, expectedStrLen);
EXPECT_FP_EQ(result, static_cast<float>(expected_fp));
EXPECT_FP_EQ(result, expected_fp.get_val());
EXPECT_EQ(libc_errno, expectedErrno);
}
};
Expand Down
2 changes: 1 addition & 1 deletion libc/utils/MPFRWrapper/MPFRUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class MPFRNumber {
if (is_nan()) {
if (FPBits<T>(input).is_nan())
return MPFRNumber(0.0);
return MPFRNumber(static_cast<T>(FPBits<T>::inf()));
return MPFRNumber(FPBits<T>::inf().get_val());
}

int thisExponent = FPBits<T>(thisAsT).get_exponent();
Expand Down