[libc-commits] [libc] [libc][math][c23] Add exp2m1f C23 math function (PR #86996)

via libc-commits libc-commits at lists.llvm.org
Mon Apr 1 14:40:35 PDT 2024


================
@@ -223,6 +229,30 @@ class MPFRNumber {
     return result;
   }
 
+  MPFRNumber
+  exp2m1([[maybe_unused]] const MPFRNumber &underflow_rndz_fallback) const {
+    // TODO: Only use mpfr_exp2m1 once CI and buildbots get MPFR >= 4.2.0.
+#if MPFR_VERSION_MAJOR > 4 ||                                                  \
+    (MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
+    MPFRNumber result(*this);
+    mpfr_exp2m1(result.value, value, mpfr_rounding);
+    return result;
+#else
+    MPFRNumber result(*this, mpfr_precision * 8);
----------------
overmighty wrote:

Looks like calling `mpfr_exp2` with `MPFR_RNDU` when `mpfr_rounding` is `MPFR_RNDZ` fixes it.

https://github.com/llvm/llvm-project/pull/86996


More information about the libc-commits mailing list