Commit 9ca2b0db by Paul Brook Committed by Paul Brook

re PR fortran/17190 (MPFR semantics for mpfr_get_z_exp changed)

	PR fortran/17190
	* arith.c (gfc_mpfr_to_mpz): Workaround mpfr bug.

From-SVN: r86581
parent ef79d4c2
2004-08-25 Paul Brook <paul@codesourcery.com> 2004-08-25 Paul Brook <paul@codesourcery.com>
PR fortran/17190
* arith.c (gfc_mpfr_to_mpz): Workaround mpfr bug.
2004-08-25 Paul Brook <paul@codesourcery.com>
PR fortran/17144 PR fortran/17144
* trans-array.c (gfc_trans_allocate_temp_array): Remove * trans-array.c (gfc_trans_allocate_temp_array): Remove
string_length argument. string_length argument.
......
...@@ -106,17 +106,20 @@ int gfc_index_integer_kind; ...@@ -106,17 +106,20 @@ int gfc_index_integer_kind;
It's easily implemented with a few calls though. */ It's easily implemented with a few calls though. */
void void
gfc_mpfr_to_mpz(mpz_t z, mpfr_t x) gfc_mpfr_to_mpz (mpz_t z, mpfr_t x)
{ {
mp_exp_t e; mp_exp_t e;
e = mpfr_get_z_exp (z, x); e = mpfr_get_z_exp (z, x);
/* MPFR 2.0.1 (included with GMP 4.1) has a bug whereby mpfr_get_z_exp
may set the sign of z incorrectly. Work around that here. */
if (mpfr_sgn (x) != mpz_sgn (z))
mpz_neg (z, z);
if (e > 0) if (e > 0)
mpz_mul_2exp (z, z, e); mpz_mul_2exp (z, z, e);
else else
mpz_tdiv_q_2exp (z, z, -e); mpz_tdiv_q_2exp (z, z, -e);
if (mpfr_sgn (x) < 0)
mpz_neg (z, z);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment