[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:31:47 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:

```
-- Testing for FE_TOWARDZERO in range [0x80000000, 0xff800000) --
/home/overmighty/projects/llvm-project/libc/test/src/math/exhaustive/exhaustive_test.h:64: FAILURE
Failed to match FUNC(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<Op>( x, FUNC(x), 0.5, rounding).
Match value not within tolerance value of MPFR result:
  Input decimal: -0.00000000000000000000000000000000000001178142104271
     Input bits: 0x808049CF = (S: 1, E: 0x0001, M: 0x000049CF)

  Match decimal: -0.00000000000000000000000000000000000000816625737744
     Match bits: 0x8058EC34 = (S: 1, E: 0x0000, M: 0x0058EC34)

    MPFR result: -0.00000000000000000000000000000000000000816625877874
   MPFR rounded: 0x8058EC35 = (S: 1, E: 0x0000, M: 0x0058EC35)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/overmighty/projects/llvm-project/libc/test/src/math/exhaustive/exhaustive_test.h:64: FAILURE
Failed to match FUNC(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<Op>( x, FUNC(x), 0.5, rounding).
Match value not within tolerance value of MPFR result:
  Input decimal: -0.00000000000000000000000000000000000002356284208541
     Input bits: 0x810049CF = (S: 1, E: 0x0002, M: 0x000049CF)

  Match decimal: -0.00000000000000000000000000000000000001633251615619
     Match bits: 0x80B1D869 = (S: 1, E: 0x0001, M: 0x0031D869)

    MPFR result: -0.00000000000000000000000000000000000001633251755748
   MPFR rounded: 0x80B1D86A = (S: 1, E: 0x0001, M: 0x0031D86A)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/overmighty/projects/llvm-project/libc/test/src/math/exhaustive/exhaustive_test.h:64: FAILURE
Failed to match FUNC(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<Op>( x, FUNC(x), 0.5, rounding).
Match value not within tolerance value of MPFR result:
  Input decimal: -0.00000000000000000000000000000000000000449061226916
     Input bits: 0x8030E600 = (S: 1, E: 0x0000, M: 0x0030E600)

  Match decimal: -0.00000000000000000000000000000000000000311265383206
     Match bits: 0x8021E4D0 = (S: 1, E: 0x0000, M: 0x0021E4D0)

    MPFR result: -0.00000000000000000000000000000000000000311265523336
   MPFR rounded: 0x8021E4D1 = (S: 1, E: 0x0000, M: 0x0021E4D1)

      ULP error: 1.00000000000000000000000000000000000000000000000000
```

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


More information about the libc-commits mailing list