[libc-commits] [libc] [libc][math][c23] Add acospif16() function (PR #134664)
via libc-commits
libc-commits at lists.llvm.org
Thu Apr 17 10:37:53 PDT 2025
================
@@ -70,6 +70,25 @@ MPFRNumber MPFRNumber::acosh() const {
return result;
}
+MPFRNumber MPFRNumber::acospi() const {
+ MPFRNumber result(*this);
+
+#if MPFR_VERSION_MAJOR > 4 || \
+ (MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
+ mpfr_acospi(result.value, value, mpfr_rounding);
+ return result;
+#else
+ if (result.is_nan()) {
+ return result;
+ }
+ mpfr_acos(result.value, value, mpfr_rounding);
+ MPFRNumber value_pi(0.0, 1280);
+ mpfr_const_pi(value_pi.value, MPFR_RNDN);
+ mpfr_div(result.value, value, value_pi.value, mpfr_rounding);
+ return result;
----------------
amemov wrote:
Thanks for the feedback. I was originally going to follow [MPFR's implementation](https://gitlab.inria.fr/mpfr/mpfr/-/blob/master/src/acosu.c) for acospi, but when I checked the examples of workarounds I thought it wouldn't be necessary - so I decided to at least start with something simple to verify that acospif16.cpp works fine for all ranges of values
https://github.com/llvm/llvm-project/pull/134664
More information about the libc-commits
mailing list