diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2023-12-15 13:57:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-15 13:57:35 +0100 |
| commit | 3546f4da1975ec65c1ccc5a2372f050c2a9b92aa (patch) | |
| tree | 082931360d1fe1b3f5a2c56f2786bf799e983287 /libc/src/math/generic/expm1.cpp | |
| parent | 3a31cf88538ed5282fce5408a48e48265e019ca6 (diff) | |
[libc][NFC] Rename `MANTISSA_WIDTH` in `FRACTION_LEN` (#75489)
This one might be a bit controversial since the terminology has been
introduced from the start but I think `FRACTION_LEN` is a better name
here. AFAICT it really is "the number of bits after the decimal dot when
the number is in normal form."
`MANTISSA_WIDTH` is less precise as it's unclear whether we take the
leading bit into account.
This patch also renames most of the properties to use the `_LEN` suffix
and fixes useless casts or variables.
Diffstat (limited to 'libc/src/math/generic/expm1.cpp')
| -rw-r--r-- | libc/src/math/generic/expm1.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libc/src/math/generic/expm1.cpp b/libc/src/math/generic/expm1.cpp index e75139548153..a0d47f00828c 100644 --- a/libc/src/math/generic/expm1.cpp +++ b/libc/src/math/generic/expm1.cpp @@ -390,7 +390,7 @@ LLVM_LIBC_FUNCTION(double, expm1, (double x)) { // -2^(-hi) double one_scaled = - FPBits::create_value(true, FPBits::EXPONENT_BIAS - hi, 0).get_val(); + FPBits::create_value(true, FPBits::EXP_BIAS - hi, 0).get_val(); // 2^(mid1 + mid2) - 2^(-hi) DoubleDouble hi_part = x_sign ? fputil::exact_add(one_scaled, exp_mid.hi) @@ -465,7 +465,7 @@ LLVM_LIBC_FUNCTION(double, expm1, (double x)) { if (LIBC_LIKELY(upper == lower)) { // to multiply by 2^hi, a fast way is to simply add hi to the exponent // field. - int64_t exp_hi = static_cast<int64_t>(hi) << FloatProp::MANTISSA_WIDTH; + int64_t exp_hi = static_cast<int64_t>(hi) << FloatProp::FRACTION_LEN; double r = cpp::bit_cast<double>(exp_hi + cpp::bit_cast<int64_t>(upper)); return r; } @@ -479,7 +479,7 @@ LLVM_LIBC_FUNCTION(double, expm1, (double x)) { double lower_dd = r_dd.hi + (r_dd.lo - err_dd); if (LIBC_LIKELY(upper_dd == lower_dd)) { - int64_t exp_hi = static_cast<int64_t>(hi) << FloatProp::MANTISSA_WIDTH; + int64_t exp_hi = static_cast<int64_t>(hi) << FloatProp::FRACTION_LEN; double r = cpp::bit_cast<double>(exp_hi + cpp::bit_cast<int64_t>(upper_dd)); return r; } |
