From: Ilia Alshanetsky Date: Wed, 30 Jan 2008 18:26:08 +0000 (+0000) Subject: MFB: Fixed bug #43981 (gmp_div_r() does not preserve the sign of 1st argument) X-Git-Tag: RELEASE_2_0_0a1~687 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a28f797952a0dc2b39f04daf7c34b19ad456d2a0;p=php MFB: Fixed bug #43981 (gmp_div_r() does not preserve the sign of 1st argument) --- diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 6445a3e25d..bbb4b7bb48 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -577,6 +577,9 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv if (use_ui && gmp_ui_op) { if (allow_ui_return) { long_result = gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); + if (mpz_sgn(*gmpnum_a) == -1) { + long_result = -long_result; + } } else { gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); }