[libc-commits] [libc] [libc][math][c23] Add atanhf16 C23 math function. (PR #132612)
via libc-commits
libc-commits at lists.llvm.org
Fri Apr 25 04:03:05 PDT 2025
================
@@ -297,6 +297,49 @@ LIBC_INLINE static double log2_eval(double x) {
return result;
}
+// x should be positive, normal finite value
+// TODO: Simplify range reduction and polynomial degree for float16.
+// See issue #137190.
+LIBC_INLINE static float log_eval_f(float x) {
+ // For x = 2^ex * (1 + mx), logf(x) = ex * logf(2) + logf(1 + mx).
+ using FPBits = fputil::FPBits<float>;
+ FPBits xbits(x);
+
+ float ex = static_cast<float>(xbits.get_exponent());
+ // p1 is the leading 7 bits of mx, i.e.
+ // p1 * 2^(-7) <= m_x < (p1 + 1) * 2^(-7).
+ int p1 = static_cast<int>(xbits.get_mantissa() >> (FPBits::FRACTION_LEN - 7));
+
+ // Set bs to (1 + (mx - p1*2^(-7))
----------------
overmighty wrote:
```suggestion
// Set bits to (1 + (mx - p1*2^(-7)))
```
https://github.com/llvm/llvm-project/pull/132612
More information about the libc-commits
mailing list