diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h index 8a6eb4b920acd..fb04d8a7775df 100644 --- a/libc/src/__support/FPUtil/Hypot.h +++ b/libc/src/__support/FPUtil/Hypot.h @@ -178,7 +178,7 @@ LIBC_INLINE T hypot(T x, T y) { // But before that, remember to store the losing bits to sticky. // The shift length is for a^2 and b^2, so it's double of the exponent // difference between a and b. - uint16_t shift_length = 2 * (a_exp - b_exp); + uint16_t shift_length = static_cast(2 * (a_exp - b_exp)); sticky_bits = ((b_mant_sq & ((DUIntType(1) << shift_length) - DUIntType(1))) != DUIntType(0)); diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h index b7920943804e6..5f0d8f49ccf64 100644 --- a/libc/src/__support/FPUtil/dyadic_float.h +++ b/libc/src/__support/FPUtil/dyadic_float.h @@ -94,7 +94,7 @@ template struct DyadicFloat { return 0.0; // Assume that it is normalized, and output is also normal. - constexpr size_t PRECISION = FloatProperties::MANTISSA_WIDTH + 1; + constexpr uint32_t PRECISION = FloatProperties::MANTISSA_PRECISION; using output_bits_t = typename FPBits::UIntType; int exp_hi = exponent + static_cast((Bits - 1) + @@ -110,12 +110,12 @@ template struct DyadicFloat { exp_hi = FloatProperties::EXPONENT_BIAS; } - int exp_lo = exp_hi - PRECISION - 1; + int exp_lo = exp_hi - static_cast(PRECISION) - 1; MantissaType m_hi(mantissa >> shift); T d_hi = FPBits::create_value(sign, exp_hi, - output_bits_t(m_hi) & + static_cast(m_hi) & FloatProperties::MANTISSA_MASK) .get_val(); diff --git a/libc/src/math/generic/explogxf.h b/libc/src/math/generic/explogxf.h index 512785be2cb85..156c24c21e231 100644 --- a/libc/src/math/generic/explogxf.h +++ b/libc/src/math/generic/explogxf.h @@ -311,7 +311,8 @@ 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 = (bs.get_mantissa() >> (FPB::FloatProp::MANTISSA_WIDTH - 7)); + int p1 = static_cast(bs.get_mantissa() >> + (FPB::FloatProp::MANTISSA_WIDTH - 7)); // Set bs to (1 + (mx - p1*2^(-7)) bs.bits &= FPB::FloatProp::MANTISSA_MASK >> 7; diff --git a/libc/src/math/generic/log.cpp b/libc/src/math/generic/log.cpp index 46b64df689086..dfa41ad64578d 100644 --- a/libc/src/math/generic/log.cpp +++ b/libc/src/math/generic/log.cpp @@ -769,7 +769,7 @@ LLVM_LIBC_FUNCTION(double, log, (double x)) { // Range reduction for log(x_m): // For each x_m, we would like to find r such that: // -2^-8 <= r * x_m - 1 < 2^-7 - int shifted = x_u >> 45; + int shifted = static_cast(x_u >> 45); int index = shifted & 0x7F; double r = RD[index]; diff --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp index 38789acc441e5..2a801c6e98429 100644 --- a/libc/src/math/generic/log10.cpp +++ b/libc/src/math/generic/log10.cpp @@ -770,7 +770,7 @@ LLVM_LIBC_FUNCTION(double, log10, (double x)) { // Range reduction for log10(x_m): // For each x_m, we would like to find r such that: // -2^-8 <= r * x_m - 1 < 2^-7 - int shifted = x_u >> 45; + int shifted = static_cast(x_u >> 45); int index = shifted & 0x7F; double r = RD[index]; diff --git a/libc/src/math/generic/log1p.cpp b/libc/src/math/generic/log1p.cpp index c6ee8d8f9bbfb..02299e271770a 100644 --- a/libc/src/math/generic/log1p.cpp +++ b/libc/src/math/generic/log1p.cpp @@ -949,8 +949,9 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) { x_u = xhi_bits.uintval(); // Range reduction: // Find k such that |x_hi - k * 2^-7| <= 2^-8. - int idx = ((x_u & MANTISSA_MASK) + (1ULL << (MANTISSA_WIDTH - 8))) >> - (MANTISSA_WIDTH - 7); + int idx = static_cast( + ((x_u & MANTISSA_MASK) + (1ULL << (MANTISSA_WIDTH - 8))) >> + (MANTISSA_WIDTH - 7)); int x_e = xhi_bits.get_exponent() + (idx >> 7); double e_x = static_cast(x_e); diff --git a/libc/src/math/generic/log1pf.cpp b/libc/src/math/generic/log1pf.cpp index 5b4e7edcceb47..023387d8add00 100644 --- a/libc/src/math/generic/log1pf.cpp +++ b/libc/src/math/generic/log1pf.cpp @@ -56,8 +56,8 @@ LIBC_INLINE float log(double x) { // Get the 8 highest bits, use 7 bits (excluding the implicit hidden bit) for // lookup tables. - int f_index = - xbits.get_mantissa() >> 45; // fputil::MantissaWidth::VALUE - 7 + int f_index = static_cast( + xbits.get_mantissa() >> 45); // fputil::MantissaWidth::VALUE - 7 // Set bits to 1.m xbits.set_unbiased_exponent(0x3FF); diff --git a/libc/src/math/generic/log2.cpp b/libc/src/math/generic/log2.cpp index d72b0931c14b8..2ceddf87dfd56 100644 --- a/libc/src/math/generic/log2.cpp +++ b/libc/src/math/generic/log2.cpp @@ -890,7 +890,7 @@ LLVM_LIBC_FUNCTION(double, log2, (double x)) { // Range reduction for log2(x_m): // For each x_m, we would like to find r such that: // -2^-8 <= r * x_m - 1 < 2^-7 - int shifted = x_u >> 45; + int shifted = static_cast(x_u >> 45); int index = shifted & 0x7F; double r = RD[index];