Skip to content

Commit 6b428aa

Browse files
committed
improved fix for mpfr_cospi() implementation for when MPFR version < 4.2
1 parent 5d620c2 commit 6b428aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libc/utils/MPFRWrapper/MPFRUtils.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ class MPFRNumber {
256256
return result;
257257
#else
258258
if (mpfr_integer_p(value)) {
259-
auto d = mpfr_get_si(value, mpfr_rounding);
260-
mpfr_set_si(result.value, (d & 1) ? -1 : 1, mpfr_rounding);
259+
mpz_t integer;
260+
mpz_init(integer);
261+
mpfr_get_z(integer, value, mpfr_rounding);
262+
263+
mpfr_set_si(result.value, (mpz_tstbit(integer, 0)) ? -1 : 1, mpfr_rounding);
261264
return result;
262265
}
263266

0 commit comments

Comments
 (0)