[libc-commits] [libc] [libc][math][c23] Add cospif16 function (PR #113001)
via libc-commits
libc-commits at lists.llvm.org
Tue Oct 29 01:45:51 PDT 2024
================
@@ -255,19 +255,13 @@ class MPFRNumber {
mpfr_cospi(result.value, value, mpfr_rounding);
return result;
#else
- MPFRNumber value_frac(*this);
- mpfr_frac(value_frac.value, value, MPFR_RNDN);
-
- if (mpfr_cmp_si(value_frac.value, 0.0) == 0) {
- mpz_t integer_part;
- mpz_init(integer_part);
- mpfr_get_z(integer_part, value, MPFR_RNDN);
-
- if (mpz_tstbit(integer_part, 0)) {
- mpfr_set_si(result.value, -1.0, MPFR_RNDN); // odd
- } else {
- mpfr_set_si(result.value, 1.0, MPFR_RNDN); // even
- }
+ if (mpfr_integer_p(value)) {
+ mpz_t integer;
+ mpz_init(integer);
+ mpfr_get_z(integer, value, mpfr_rounding);
+
+ auto d = mpz_tstbit(integer, 0);
----------------
overmighty wrote:
`mpz_tstbit` returns an `int` as far as I can tell. Should probably just use `int` directly instead of `auto`.
https://github.com/llvm/llvm-project/pull/113001
More information about the libc-commits
mailing list