10 changes: 5 additions & 5 deletions libc/src/__support/str_to_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LIBC_INLINE cpp::optional<ExpandedFloat<T>>
eisel_lemire(ExpandedFloat<T> init_num,
RoundDirection round = RoundDirection::Nearest) {
using FPBits = typename fputil::FPBits<T>;
using FloatProp = typename FPBits::FloatProp;
using FloatProp = typename fputil::FloatProperties<T>;
using UIntType = typename FPBits::UIntType;

UIntType mantissa = init_num.mantissa;
Expand Down Expand Up @@ -184,7 +184,7 @@ LIBC_INLINE cpp::optional<ExpandedFloat<long double>>
eisel_lemire<long double>(ExpandedFloat<long double> init_num,
RoundDirection round) {
using FPBits = typename fputil::FPBits<long double>;
using FloatProp = typename FPBits::FloatProp;
using FloatProp = typename fputil::FloatProperties<long double>;
using UIntType = typename FPBits::UIntType;

UIntType mantissa = init_num.mantissa;
Expand Down Expand Up @@ -322,7 +322,7 @@ LIBC_INLINE FloatConvertReturn<T>
simple_decimal_conversion(const char *__restrict numStart,
RoundDirection round = RoundDirection::Nearest) {
using FPBits = typename fputil::FPBits<T>;
using FloatProp = typename FPBits::FloatProp;
using FloatProp = typename fputil::FloatProperties<T>;
using UIntType = typename FPBits::UIntType;

int32_t exp2 = 0;
Expand Down Expand Up @@ -516,7 +516,7 @@ LIBC_INLINE cpp::optional<ExpandedFloat<T>>
clinger_fast_path(ExpandedFloat<T> init_num,
RoundDirection round = RoundDirection::Nearest) {
using FPBits = typename fputil::FPBits<T>;
using FloatProp = typename FPBits::FloatProp;
using FloatProp = typename fputil::FloatProperties<T>;
using UIntType = typename FPBits::UIntType;

UIntType mantissa = init_num.mantissa;
Expand Down Expand Up @@ -724,7 +724,7 @@ LIBC_INLINE FloatConvertReturn<T> binary_exp_to_float(ExpandedFloat<T> init_num,
bool truncated,
RoundDirection round) {
using FPBits = typename fputil::FPBits<T>;
using FloatProp = typename FPBits::FloatProp;
using FloatProp = typename fputil::FloatProperties<T>;
using UIntType = typename FPBits::UIntType;

UIntType mantissa = init_num.mantissa;
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/acoshf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LLVM_LIBC_FUNCTION(float, acoshf, (float x)) {

if (LIBC_UNLIKELY(x_u >= 0x4f8ffb03)) {
// Check for exceptional values.
uint32_t x_abs = x_u & FPBits_t::FloatProp::EXP_MANT_MASK;
uint32_t x_abs = x_u & FPBits_t::EXP_MANT_MASK;
if (LIBC_UNLIKELY(x_abs >= 0x7f80'0000U)) {
// x is +inf or NaN.
return x;
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/asinhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LLVM_LIBC_FUNCTION(float, asinhf, (float x)) {
using FPBits_t = typename fputil::FPBits<float>;
FPBits_t xbits(x);
uint32_t x_u = xbits.uintval();
uint32_t x_abs = x_u & FPBits_t::FloatProp::EXP_MANT_MASK;
uint32_t x_abs = x_u & FPBits_t::EXP_MANT_MASK;

// |x| <= 2^-3
if (LIBC_UNLIKELY(x_abs <= 0x3e80'0000U)) {
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/atanhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LLVM_LIBC_FUNCTION(float, atanhf, (float x)) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
bool sign = xbits.get_sign();
uint32_t x_abs = xbits.uintval() & FPBits::FloatProp::EXP_MANT_MASK;
uint32_t x_abs = xbits.uintval() & FPBits::EXP_MANT_MASK;

// |x| >= 1.0
if (LIBC_UNLIKELY(x_abs >= 0x3F80'0000U)) {
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/erff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ LLVM_LIBC_FUNCTION(float, erff, (float x)) {
double xd = static_cast<double>(x);
double xsq = xd * xd;

const uint32_t EIGHT = 3 << FPBits::FloatProp::MANTISSA_WIDTH;
const uint32_t EIGHT = 3 << FPBits::MANTISSA_WIDTH;
int idx = static_cast<int>(FPBits(x_abs + EIGHT).get_val());

double x4 = xsq * xsq;
Expand Down
16 changes: 7 additions & 9 deletions libc/src/math/generic/explogxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,11 @@ LIBC_INLINE static double log2_eval(double x) {
double result = 0;
result += bs.get_exponent();

int p1 =
(bs.get_mantissa() >> (FPB::FloatProp::MANTISSA_WIDTH - LOG_P1_BITS)) &
(LOG_P1_SIZE - 1);
int p1 = (bs.get_mantissa() >> (FPB::MANTISSA_WIDTH - LOG_P1_BITS)) &
(LOG_P1_SIZE - 1);

bs.bits &= FPB::FloatProp::MANTISSA_MASK >> LOG_P1_BITS;
bs.set_biased_exponent(FPB::FloatProp::EXPONENT_BIAS);
bs.bits &= FPB::MANTISSA_MASK >> LOG_P1_BITS;
bs.set_biased_exponent(FPB::EXPONENT_BIAS);
double dx = (bs.get_val() - 1.0) * LOG_P1_1_OVER[p1];

// Taylor series for log(2,1+x)
Expand All @@ -311,12 +310,11 @@ LIBC_INLINE static double log_eval(double x) {

// p1 is the leading 7 bits of mx, i.e.
// p1 * 2^(-7) <= m_x < (p1 + 1) * 2^(-7).
int p1 = static_cast<int>(bs.get_mantissa() >>
(FPB::FloatProp::MANTISSA_WIDTH - 7));
int p1 = static_cast<int>(bs.get_mantissa() >> (FPB::MANTISSA_WIDTH - 7));

// Set bs to (1 + (mx - p1*2^(-7))
bs.bits &= FPB::FloatProp::MANTISSA_MASK >> 7;
bs.set_biased_exponent(FPB::FloatProp::EXPONENT_BIAS);
bs.bits &= FPB::MANTISSA_MASK >> 7;
bs.set_biased_exponent(FPB::EXPONENT_BIAS);
// dx = (mx - p1*2^(-7)) / (1 + p1*2^(-7)).
double dx = (bs.get_val() - 1.0) * ONE_OVER_F[p1];

Expand Down
5 changes: 3 additions & 2 deletions libc/src/math/generic/inv_trigf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ LIBC_INLINE double atan_eval(double x) {

FPB bs(x);
bool sign = bs.get_sign();
auto x_abs = bs.uintval() & FPB::FloatProp::EXP_MANT_MASK;
auto x_abs = bs.uintval() & FPB::EXP_MANT_MASK;

if (x_abs <= umin) {
double pe = LIBC_NAMESPACE::fputil::polyeval(
Expand All @@ -64,7 +64,8 @@ LIBC_INLINE double atan_eval(double x) {
double one_over_x2 = one_over_x_m * one_over_x_m;
double pe = LIBC_NAMESPACE::fputil::polyeval(
one_over_x2, ATAN_K[0], ATAN_K[1], ATAN_K[2], ATAN_K[3]);
return fputil::multiply_add(pe, one_over_x_m, sign ? (-M_MATH_PI_2) : (M_MATH_PI_2));
return fputil::multiply_add(pe, one_over_x_m,
sign ? (-M_MATH_PI_2) : (M_MATH_PI_2));
}

double pos_x = FPB(x_abs).get_val();
Expand Down
6 changes: 3 additions & 3 deletions libc/src/math/generic/log1p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ LIBC_INLINE double log1p_accurate(int e_x, int index,
LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
using FPBits_t = typename fputil::FPBits<double>;
constexpr int EXPONENT_BIAS = FPBits_t::EXPONENT_BIAS;
constexpr int MANTISSA_WIDTH = FPBits_t::FloatProp::MANTISSA_WIDTH;
constexpr uint64_t MANTISSA_MASK = FPBits_t::FloatProp::MANTISSA_MASK;
constexpr int MANTISSA_WIDTH = FPBits_t::MANTISSA_WIDTH;
constexpr uint64_t MANTISSA_MASK = FPBits_t::MANTISSA_MASK;
FPBits_t xbits(x);
uint64_t x_u = xbits.uintval();

Expand Down Expand Up @@ -969,7 +969,7 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
// Scaling factior = 2^(-xh_bits.get_exponent())
uint64_t s_u =
(static_cast<uint64_t>(EXPONENT_BIAS) << (MANTISSA_WIDTH + 1)) -
(x_u & FPBits_t::FloatProp::EXPONENT_MASK);
(x_u & FPBits_t::EXPONENT_MASK);
// When the exponent of x is 2^1023, its inverse, 2^(-1023), is subnormal.
const double EXPONENT_CORRECTION[2] = {0.0, 0x1.0p-1023};
double scaling = FPBits_t(s_u).get_val() + EXPONENT_CORRECTION[s_u == 0];
Expand Down
5 changes: 2 additions & 3 deletions libc/src/math/generic/sinhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
uint32_t x_abs = xbits.uintval() & FPBits::FloatProp::EXP_MANT_MASK;
uint32_t x_abs = xbits.uintval() & FPBits::EXP_MANT_MASK;

// When |x| >= 90, or x is inf or nan
if (LIBC_UNLIKELY(x_abs >= 0x42b4'0000U || x_abs <= 0x3da0'0000U)) {
Expand Down Expand Up @@ -57,8 +57,7 @@ LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
int rounding = fputil::quick_get_round();
if (sign) {
if (LIBC_UNLIKELY(rounding == FE_UPWARD || rounding == FE_TOWARDZERO))
return FPBits(FPBits::MAX_NORMAL | FPBits::FloatProp::SIGN_MASK)
.get_val();
return FPBits(FPBits::MAX_NORMAL | FPBits::SIGN_MASK).get_val();
} else {
if (LIBC_UNLIKELY(rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO))
return FPBits(FPBits::MAX_NORMAL).get_val();
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/tanhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LLVM_LIBC_FUNCTION(float, tanhf, (float x)) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
uint32_t x_u = xbits.uintval();
uint32_t x_abs = x_u & FPBits::FloatProp::EXP_MANT_MASK;
uint32_t x_abs = x_u & FPBits::EXP_MANT_MASK;

// When |x| >= 15, or x is inf or nan, or |x| <= 0.078125
if (LIBC_UNLIKELY((x_abs >= 0x4170'0000U) || (x_abs <= 0x3da0'0000U))) {
Expand Down