summaryrefslogtreecommitdiff
path: root/libc/test/src/math
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2024-01-23 17:30:19 +0100
committerGitHub <noreply@github.com>2024-01-23 17:30:19 +0100
commit2856db0d3b691907e055265c10f3ccc9b04f594e (patch)
treee513ffb77746d6f5ba227d8c28874378eb9061e6 /libc/test/src/math
parente1aa5b1fd12d548863cf73c1ec09f98fe89d117b (diff)
[libc][NFC] Remove `FPBits` cast operator (#79142)
The semantics for casting can range from "bitcast" (same representation) to "different representation", to "type promotion". Here we remove the cast operator and force usage of `get_val` as the only function to get the floating point value, making the intent clearer and more consistent.
Diffstat (limited to 'libc/test/src/math')
-rw-r--r--libc/test/src/math/CeilTest.h2
-rw-r--r--libc/test/src/math/CopySignTest.h2
-rw-r--r--libc/test/src/math/FAbsTest.h2
-rw-r--r--libc/test/src/math/FDimTest.h12
-rw-r--r--libc/test/src/math/FMaxTest.h2
-rw-r--r--libc/test/src/math/FMinTest.h2
-rw-r--r--libc/test/src/math/FloorTest.h2
-rw-r--r--libc/test/src/math/FmaTest.h28
-rw-r--r--libc/test/src/math/FrexpTest.h2
-rw-r--r--libc/test/src/math/HypotTest.h22
-rw-r--r--libc/test/src/math/ILogbTest.h14
-rw-r--r--libc/test/src/math/LdExpTest.h10
-rw-r--r--libc/test/src/math/LogbTest.h2
-rw-r--r--libc/test/src/math/ModfTest.h2
-rw-r--r--libc/test/src/math/NextAfterTest.h10
-rw-r--r--libc/test/src/math/RIntTest.h14
-rw-r--r--libc/test/src/math/RemQuoTest.h14
-rw-r--r--libc/test/src/math/RoundTest.h2
-rw-r--r--libc/test/src/math/RoundToIntegerTest.h18
-rw-r--r--libc/test/src/math/SqrtTest.h2
-rw-r--r--libc/test/src/math/TruncTest.h2
-rw-r--r--libc/test/src/math/acosf_test.cpp4
-rw-r--r--libc/test/src/math/acoshf_test.cpp4
-rw-r--r--libc/test/src/math/asinf_test.cpp4
-rw-r--r--libc/test/src/math/asinhf_test.cpp4
-rw-r--r--libc/test/src/math/atanf_test.cpp4
-rw-r--r--libc/test/src/math/atanhf_test.cpp6
-rw-r--r--libc/test/src/math/cos_test.cpp2
-rw-r--r--libc/test/src/math/cosf_test.cpp6
-rw-r--r--libc/test/src/math/coshf_test.cpp12
-rw-r--r--libc/test/src/math/erff_test.cpp2
-rw-r--r--libc/test/src/math/exhaustive/exhaustive_test.h7
-rw-r--r--libc/test/src/math/exhaustive/hypotf_test.cpp4
-rw-r--r--libc/test/src/math/exhaustive/sincosf_test.cpp2
-rw-r--r--libc/test/src/math/exp10_test.cpp2
-rw-r--r--libc/test/src/math/exp10f_test.cpp17
-rw-r--r--libc/test/src/math/exp2_test.cpp2
-rw-r--r--libc/test/src/math/exp2f_test.cpp18
-rw-r--r--libc/test/src/math/exp_test.cpp2
-rw-r--r--libc/test/src/math/expf_test.cpp24
-rw-r--r--libc/test/src/math/expm1_test.cpp2
-rw-r--r--libc/test/src/math/expm1f_test.cpp30
-rw-r--r--libc/test/src/math/log10_test.cpp2
-rw-r--r--libc/test/src/math/log10f_test.cpp4
-rw-r--r--libc/test/src/math/log1p_test.cpp2
-rw-r--r--libc/test/src/math/log1pf_test.cpp4
-rw-r--r--libc/test/src/math/log2_test.cpp2
-rw-r--r--libc/test/src/math/log2f_test.cpp4
-rw-r--r--libc/test/src/math/log_test.cpp2
-rw-r--r--libc/test/src/math/logf_test.cpp4
-rw-r--r--libc/test/src/math/sin_test.cpp2
-rw-r--r--libc/test/src/math/sincosf_test.cpp6
-rw-r--r--libc/test/src/math/sinf_test.cpp10
-rw-r--r--libc/test/src/math/sinhf_test.cpp16
-rw-r--r--libc/test/src/math/smoke/FDimTest.h12
-rw-r--r--libc/test/src/math/smoke/FMaxTest.h2
-rw-r--r--libc/test/src/math/smoke/FMinTest.h2
-rw-r--r--libc/test/src/math/smoke/FmaTest.h24
-rw-r--r--libc/test/src/math/smoke/HypotTest.h20
-rw-r--r--libc/test/src/math/smoke/ILogbTest.h14
-rw-r--r--libc/test/src/math/smoke/LdExpTest.h10
-rw-r--r--libc/test/src/math/smoke/LogbTest.h2
-rw-r--r--libc/test/src/math/smoke/ModfTest.h2
-rw-r--r--libc/test/src/math/smoke/NextAfterTest.h10
-rw-r--r--libc/test/src/math/smoke/NextTowardTest.h10
-rw-r--r--libc/test/src/math/smoke/RIntTest.h10
-rw-r--r--libc/test/src/math/smoke/RemQuoTest.h10
-rw-r--r--libc/test/src/math/smoke/RoundToIntegerTest.h12
-rw-r--r--libc/test/src/math/smoke/coshf_test.cpp6
-rw-r--r--libc/test/src/math/smoke/exp10f_test.cpp6
-rw-r--r--libc/test/src/math/smoke/exp2f_test.cpp6
-rw-r--r--libc/test/src/math/smoke/expf_test.cpp6
-rw-r--r--libc/test/src/math/smoke/expm1f_test.cpp6
-rw-r--r--libc/test/src/math/smoke/sinhf_test.cpp10
-rw-r--r--libc/test/src/math/tan_test.cpp2
-rw-r--r--libc/test/src/math/tanf_test.cpp6
-rw-r--r--libc/test/src/math/tanhf_test.cpp4
77 files changed, 287 insertions, 287 deletions
diff --git a/libc/test/src/math/CeilTest.h b/libc/test/src/math/CeilTest.h
index 67b33cb14110..5ea4f349d008 100644
--- a/libc/test/src/math/CeilTest.h
+++ b/libc/test/src/math/CeilTest.h
@@ -67,7 +67,7 @@ public:
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;
diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h
index c916416a2e5b..8b81e8d7de25 100644
--- a/libc/test/src/math/CopySignTest.h
+++ b/libc/test/src/math/CopySignTest.h
@@ -37,7 +37,7 @@ public:
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;
diff --git a/libc/test/src/math/FAbsTest.h b/libc/test/src/math/FAbsTest.h
index b2b146167e62..bf3052afc816 100644
--- a/libc/test/src/math/FAbsTest.h
+++ b/libc/test/src/math/FAbsTest.h
@@ -35,7 +35,7 @@ public:
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);
diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h
index 46df2b40e64b..31df2f5607c2 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -20,11 +20,11 @@ public:
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));
@@ -66,7 +66,7 @@ public:
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))
diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h
index 1a1d2a77268d..edc46ae5bb0f 100644
--- a/libc/test/src/math/FMaxTest.h
+++ b/libc/test/src/math/FMaxTest.h
@@ -59,7 +59,7 @@ public:
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))
diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h
index 742bb5cdd102..5ff583604ebc 100644
--- a/libc/test/src/math/FMinTest.h
+++ b/libc/test/src/math/FMinTest.h
@@ -59,7 +59,7 @@ public:
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))
diff --git a/libc/test/src/math/FloorTest.h b/libc/test/src/math/FloorTest.h
index c1b05c5d1308..5e459ebd4928 100644
--- a/libc/test/src/math/FloorTest.h
+++ b/libc/test/src/math/FloorTest.h
@@ -67,7 +67,7 @@ public:
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;
diff --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h
index 8cc340e9260f..dd6832e12914 100644
--- a/libc/test/src/math/FmaTest.h
+++ b/libc/test/src/math/FmaTest.h
@@ -25,14 +25,14 @@ private:
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();
@@ -63,9 +63,9 @@ public:
// 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;
@@ -80,8 +80,8 @@ public:
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);
@@ -93,8 +93,8 @@ public:
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);
diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h
index 20ddce807da4..f3a64ce4aac3 100644
--- a/libc/test/src/math/FrexpTest.h
+++ b/libc/test/src/math/FrexpTest.h
@@ -96,7 +96,7 @@ public:
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;
diff --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h
index 2990072fd5c6..9f2d148be6b9 100644
--- a/libc/test/src/math/HypotTest.h
+++ b/libc/test/src/math/HypotTest.h
@@ -25,15 +25,15 @@ private:
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();
@@ -74,7 +74,7 @@ public:
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;
}
@@ -96,7 +96,7 @@ public:
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;
}
diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h
index fe28fab9d777..fb8d77093eba 100644
--- a/libc/test/src/math/ILogbTest.h
+++ b/libc/test/src/math/ILogbTest.h
@@ -26,11 +26,11 @@ public:
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>
@@ -81,7 +81,7 @@ public:
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;
@@ -100,7 +100,7 @@ public:
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;
diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h
index 08a14a90c122..1d581f2c0a02 100644
--- a/libc/test/src/math/LdExpTest.h
+++ b/libc/test/src/math/LdExpTest.h
@@ -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;
diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h
index 196da5e96b07..d64c5c44e428 100644
--- a/libc/test/src/math/LogbTest.h
+++ b/libc/test/src/math/LogbTest.h
@@ -75,7 +75,7 @@ public:
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;
diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h
index f5196a74fa74..a7e5e8810611 100644
--- a/libc/test/src/math/ModfTest.h
+++ b/libc/test/src/math/ModfTest.h
@@ -87,7 +87,7 @@ public:
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;
diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h
index f9ae4a4ec5c0..2bbc3891205a 100644
--- a/libc/test/src/math/NextAfterTest.h
+++ b/libc/test/src/math/NextAfterTest.h
@@ -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();
diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 3af7b6fe6f6d..c6693981df5e 100644
--- a/libc/test/src/math/RIntTest.h
+++ b/libc/test/src/math/RIntTest.h
@@ -34,11 +34,11 @@ private:
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();
@@ -104,7 +104,7 @@ public:
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);
@@ -117,7 +117,7 @@ public:
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)) {
diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index bbc266764c1c..16a439a5fea6 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -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();
@@ -107,7 +107,7 @@ public:
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);
@@ -120,7 +120,7 @@ public:
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);
diff --git a/libc/test/src/math/RoundTest.h b/libc/test/src/math/RoundTest.h
index 3ec46159c65d..4860464be908 100644
--- a/libc/test/src/math/RoundTest.h
+++ b/libc/test/src/math/RoundTest.h
@@ -67,7 +67,7 @@ public:
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;
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index f75aaa348bd0..a2a88c75a733 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -33,11 +33,11 @@ private:
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();
@@ -139,7 +139,7 @@ public:
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);
@@ -203,7 +203,7 @@ public:
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);
@@ -225,7 +225,7 @@ public:
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.
@@ -267,7 +267,7 @@ public:
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)) {
diff --git a/libc/test/src/math/SqrtTest.h b/libc/test/src/math/SqrtTest.h
index d58c3ccfdd5a..75eb411810f5 100644
--- a/libc/test/src/math/SqrtTest.h
+++ b/libc/test/src/math/SqrtTest.h
@@ -41,7 +41,7 @@ public:
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);
}
diff --git a/libc/test/src/math/TruncTest.h b/libc/test/src/math/TruncTest.h
index 2be40790258e..0d99363526e8 100644
--- a/libc/test/src/math/TruncTest.h
+++ b/libc/test/src/math/TruncTest.h
@@ -67,7 +67,7 @@ public:
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;
diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index 409cf2bc8913..81f697c315a2 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -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,
@@ -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,
diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index fe8d76918d48..6d43105c83c2 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -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,
@@ -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);
}
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index db9dd0d78404..77ac2bc216f7 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -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,
@@ -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,
diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index 2afb5b3a9ff8..9b925bf254a9 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -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,
@@ -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,
diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp
index 61d202e22bdc..b5d30fbd5679 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -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,
@@ -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);
}
diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp
index fcc9f44dbea9..0080a328fbea 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -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),
@@ -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);
diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp
index a4c332bc7fb5..1f55e9e9a149 100644
--- a/libc/test/src/math/cos_test.cpp
+++ b/libc/test/src/math/cos_test.cpp
@@ -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;
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index 5a16520439af..9a988d76c598 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -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,
@@ -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,
@@ -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);
}
}
diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp
index 797cfec566ac..843ecb8925ad 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -44,15 +44,15 @@ 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);
}
@@ -60,7 +60,7 @@ 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);
@@ -68,12 +68,12 @@ TEST_F(LlvmLibcCoshfTest, InFloatRange) {
}
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);
diff --git a/libc/test/src/math/erff_test.cpp b/libc/test/src/math/erff_test.cpp
index 933f77c0b5a6..8ebde4ec24fb 100644
--- a/libc/test/src/math/erff_test.cpp
+++ b/libc/test/src/math/erff_test.cpp
@@ -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,
diff --git a/libc/test/src/math/exhaustive/exhaustive_test.h b/libc/test/src/math/exhaustive/exhaustive_test.h
index dbb59e5269dc..c4ae382688a0 100644
--- a/libc/test/src/math/exhaustive/exhaustive_test.h
+++ b/libc/test/src/math/exhaustive/exhaustive_test.h
@@ -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);
@@ -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);
diff --git a/libc/test/src/math/exhaustive/hypotf_test.cpp b/libc/test/src/math/exhaustive/hypotf_test.cpp
index df597563ab0c..04da55d4d3a9 100644
--- a/libc/test/src/math/exhaustive/hypotf_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotf_test.cpp
@@ -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.
diff --git a/libc/test/src/math/exhaustive/sincosf_test.cpp b/libc/test/src/math/exhaustive/sincosf_test.cpp
index 4104034d17c6..4d53d24f0532 100644
--- a/libc/test/src/math/exhaustive/sincosf_test.cpp
+++ b/libc/test/src/math/exhaustive/sincosf_test.cpp
@@ -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);
diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp
index ec3925846dba..e9990b3ed8e6 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp
index e3151dafa942..0866488935c2 100644
--- a/libc/test/src/math/exp10f_test.cpp
+++ b/libc/test/src/math/exp10f_test.cpp
@@ -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);
@@ -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,
@@ -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;
diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp
index 539ec7b9368f..d66c9b757625 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index 4c69c1d48d62..18607b1d0491 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -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);
}
@@ -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);
@@ -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);
@@ -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;
diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp
index 1de2d7507acc..454107f307d8 100644
--- a/libc/test/src/math/exp_test.cpp
+++ b/libc/test/src/math/exp_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp
index 521eba705b69..0ac64ceec1c7 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -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);
@@ -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);
@@ -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;
diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp
index ad53ffb6e8af..99ef8275eab7 100644
--- a/libc/test/src/math/expm1_test.cpp
+++ b/libc/test/src/math/expm1_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp
index a9eaa4dbe538..cc820803cc30 100644
--- a/libc/test/src/math/expm1f_test.cpp
+++ b/libc/test/src/math/expm1f_test.cpp
@@ -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));
}
@@ -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);
@@ -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;
diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index 72224c247180..de9206f2daec 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/log10f_test.cpp b/libc/test/src/math/log10f_test.cpp
index 3448ea7570ee..c38a5159682c 100644
--- a/libc/test/src/math/log10f_test.cpp
+++ b/libc/test/src/math/log10f_test.cpp
@@ -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);
}
@@ -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);
}
diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index 5bec911937dc..f70c0f87560c 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp
index 16cdc4704cb8..37144838552c 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -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);
}
@@ -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;
diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp
index b471b8eb540f..65eae58b3508 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp
index aaa6320fb26b..0793bf8a0409 100644
--- a/libc/test/src/math/log2f_test.cpp
+++ b/libc/test/src/math/log2f_test.cpp
@@ -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);
}
@@ -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;
diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp
index e3f41e1e264a..457117c1757a 100644
--- a/libc/test/src/math/log_test.cpp
+++ b/libc/test/src/math/log_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp
index c02e95cb6f80..3ab67ba80782 100644
--- a/libc/test/src/math/logf_test.cpp
+++ b/libc/test/src/math/logf_test.cpp
@@ -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);
}
@@ -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,
diff --git a/libc/test/src/math/sin_test.cpp b/libc/test/src/math/sin_test.cpp
index cd9eeaff598f..69981ed22ee6 100644
--- a/libc/test/src/math/sin_test.cpp
+++ b/libc/test/src/math/sin_test.cpp
@@ -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;
diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index fde707f892a9..76fda6354f63 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -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;
@@ -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);
}
@@ -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);
}
diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 107b01551299..32afc4f1c60d 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -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,
@@ -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,
@@ -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);
}
@@ -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);
}
diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp
index dc80a1b7aedf..765fdc6c2bcc 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -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);
@@ -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);
@@ -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);
}
diff --git a/libc/test/src/math/smoke/FDimTest.h b/libc/test/src/math/smoke/FDimTest.h
index 46df2b40e64b..31df2f5607c2 100644
--- a/libc/test/src/math/smoke/FDimTest.h
+++ b/libc/test/src/math/smoke/FDimTest.h
@@ -20,11 +20,11 @@ public:
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));
@@ -66,7 +66,7 @@ public:
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))
diff --git a/libc/test/src/math/smoke/FMaxTest.h b/libc/test/src/math/smoke/FMaxTest.h
index 372d9c5571d3..98edc8e971e8 100644
--- a/libc/test/src/math/smoke/FMaxTest.h
+++ b/libc/test/src/math/smoke/FMaxTest.h
@@ -56,7 +56,7 @@ public:
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))
diff --git a/libc/test/src/math/smoke/FMinTest.h b/libc/test/src/math/smoke/FMinTest.h
index a51f30803ba8..834d757c85d0 100644
--- a/libc/test/src/math/smoke/FMinTest.h
+++ b/libc/test/src/math/smoke/FMinTest.h
@@ -56,7 +56,7 @@ public:
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))
diff --git a/libc/test/src/math/smoke/FmaTest.h b/libc/test/src/math/smoke/FmaTest.h
index 106ba1405a96..9d76d3bde312 100644
--- a/libc/test/src/math/smoke/FmaTest.h
+++ b/libc/test/src/math/smoke/FmaTest.h
@@ -21,11 +21,11 @@ private:
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) {
@@ -39,16 +39,16 @@ public:
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));
diff --git a/libc/test/src/math/smoke/HypotTest.h b/libc/test/src/math/smoke/HypotTest.h
index 5400fc0730d8..0f3b52d53f49 100644
--- a/libc/test/src/math/smoke/HypotTest.h
+++ b/libc/test/src/math/smoke/HypotTest.h
@@ -22,16 +22,16 @@ private:
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) {
diff --git a/libc/test/src/math/smoke/ILogbTest.h b/libc/test/src/math/smoke/ILogbTest.h
index fe28fab9d777..fb8d77093eba 100644
--- a/libc/test/src/math/smoke/ILogbTest.h
+++ b/libc/test/src/math/smoke/ILogbTest.h
@@ -26,11 +26,11 @@ public:
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>
@@ -81,7 +81,7 @@ public:
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;
@@ -100,7 +100,7 @@ public:
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;
diff --git a/libc/test/src/math/smoke/LdExpTest.h b/libc/test/src/math/smoke/LdExpTest.h
index 08a14a90c122..1d581f2c0a02 100644
--- a/libc/test/src/math/smoke/LdExpTest.h
+++ b/libc/test/src/math/smoke/LdExpTest.h
@@ -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;
diff --git a/libc/test/src/math/smoke/LogbTest.h b/libc/test/src/math/smoke/LogbTest.h
index a2628273cecc..e2698e2b7b81 100644
--- a/libc/test/src/math/smoke/LogbTest.h
+++ b/libc/test/src/math/smoke/LogbTest.h
@@ -72,7 +72,7 @@ public:
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;
diff --git a/libc/test/src/math/smoke/ModfTest.h b/libc/test/src/math/smoke/ModfTest.h
index ea7e36b67d11..a73e5ae4298f 100644
--- a/libc/test/src/math/smoke/ModfTest.h
+++ b/libc/test/src/math/smoke/ModfTest.h
@@ -84,7 +84,7 @@ public:
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;
diff --git a/libc/test/src/math/smoke/NextAfterTest.h b/libc/test/src/math/smoke/NextAfterTest.h
index 859e2c74a369..d2870562b238 100644
--- a/libc/test/src/math/smoke/NextAfterTest.h
+++ b/libc/test/src/math/smoke/NextAfterTest.h
@@ -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();
diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h
index c9f07b993f04..5bbc89b9e5f7 100644
--- a/libc/test/src/math/smoke/NextTowardTest.h
+++ b/libc/test/src/math/smoke/NextTowardTest.h
@@ -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();
diff --git a/libc/test/src/math/smoke/RIntTest.h b/libc/test/src/math/smoke/RIntTest.h
index bd99e634badb..88c4c560fffa 100644
--- a/libc/test/src/math/smoke/RIntTest.h
+++ b/libc/test/src/math/smoke/RIntTest.h
@@ -31,11 +31,11 @@ private:
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) {
diff --git a/libc/test/src/math/smoke/RemQuoTest.h b/libc/test/src/math/smoke/RemQuoTest.h
index 739661f2d961..e0fbe4ee935f 100644
--- a/libc/test/src/math/smoke/RemQuoTest.h
+++ b/libc/test/src/math/smoke/RemQuoTest.h
@@ -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 *);
diff --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h
index 404155604645..836f827c1450 100644
--- a/libc/test/src/math/smoke/RoundToIntegerTest.h
+++ b/libc/test/src/math/smoke/RoundToIntegerTest.h
@@ -30,11 +30,11 @@ private:
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();
@@ -119,7 +119,7 @@ public:
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.
diff --git a/libc/test/src/math/smoke/coshf_test.cpp b/libc/test/src/math/smoke/coshf_test.cpp
index 93fdd126896c..aa224dcc156f 100644
--- a/libc/test/src/math/smoke/coshf_test.cpp
+++ b/libc/test/src/math/smoke/coshf_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/smoke/exp10f_test.cpp b/libc/test/src/math/smoke/exp10f_test.cpp
index 8b758dd3f62f..d242edf04fb3 100644
--- a/libc/test/src/math/smoke/exp10f_test.cpp
+++ b/libc/test/src/math/smoke/exp10f_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/smoke/exp2f_test.cpp b/libc/test/src/math/smoke/exp2f_test.cpp
index 6623d449aeeb..e4e56ed23bcf 100644
--- a/libc/test/src/math/smoke/exp2f_test.cpp
+++ b/libc/test/src/math/smoke/exp2f_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/smoke/expf_test.cpp b/libc/test/src/math/smoke/expf_test.cpp
index ff33e95f9042..24fc35b552ca 100644
--- a/libc/test/src/math/smoke/expf_test.cpp
+++ b/libc/test/src/math/smoke/expf_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/smoke/expm1f_test.cpp b/libc/test/src/math/smoke/expm1f_test.cpp
index 6999a987f9d6..3d6dae77ec00 100644
--- a/libc/test/src/math/smoke/expm1f_test.cpp
+++ b/libc/test/src/math/smoke/expm1f_test.cpp
@@ -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);
}
diff --git a/libc/test/src/math/smoke/sinhf_test.cpp b/libc/test/src/math/smoke/sinhf_test.cpp
index aa11ed9cbe10..0563ccbf77aa 100644
--- a/libc/test/src/math/smoke/sinhf_test.cpp
+++ b/libc/test/src/math/smoke/sinhf_test.cpp
@@ -40,11 +40,11 @@ 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);
}
@@ -52,14 +52,14 @@ 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);
}
diff --git a/libc/test/src/math/tan_test.cpp b/libc/test/src/math/tan_test.cpp
index 8fae425f96f8..9cdc7c4abd32 100644
--- a/libc/test/src/math/tan_test.cpp
+++ b/libc/test/src/math/tan_test.cpp
@@ -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;
diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp
index 6005202e754b..5621e819522f 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -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,
@@ -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,
@@ -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);
}
}
diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp
index 1dc736d36930..862ba6cc7eeb 100644
--- a/libc/test/src/math/tanhf_test.cpp
+++ b/libc/test/src/math/tanhf_test.cpp
@@ -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,
@@ -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,