Skip to content

Commit 92ebb2e

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #43981 (gmp_div_r() does not preserve the sign of 1st argument)
1 parent 1e29793 commit 92ebb2e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/gmp/gmp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
569569
if (use_ui && gmp_ui_op) {
570570
if (allow_ui_return) {
571571
long_result = gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg));
572+
if (mpz_sgn(*gmpnum_a) == -1) {
573+
long_result = -long_result;
574+
}
572575
} else {
573576
gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg));
574577
}

0 commit comments

Comments
 (0)