mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Normalize gmp_remroot() behavior to GMP 5.1
This commit is contained in:
parent
8e167a2a00
commit
7e049b0427
@ -238,6 +238,9 @@ typedef struct _gmp_temp {
|
||||
#define GMP_42_OR_NEWER \
|
||||
((__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2))
|
||||
|
||||
#define GMP_51_OR_NEWER \
|
||||
((__GNU_MP_VERSION >= 6) || (__GNU_MP_VERSION >= 5 && __GNU_MP_VERSION_MINOR >= 1))
|
||||
|
||||
/* The maximum base for input and output conversions is 62 from GMP 4.2
|
||||
* onwards. */
|
||||
#if GMP_42_OR_NEWER
|
||||
@ -1607,13 +1610,14 @@ ZEND_FUNCTION(gmp_rootrem)
|
||||
add_index_zval(return_value, 0, gmp_create(&gmpnum_result1 TSRMLS_CC));
|
||||
add_index_zval(return_value, 1, gmp_create(&gmpnum_result2 TSRMLS_CC));
|
||||
|
||||
#if GMP_42_OR_NEWER
|
||||
#if GMP_51_OR_NEWER
|
||||
/* mpz_rootrem() is supported since GMP 4.2, but buggy wrt odd roots
|
||||
* of negative numbers */
|
||||
mpz_rootrem(gmpnum_result1, gmpnum_result2, gmpnum_a, (unsigned long) nth);
|
||||
#else
|
||||
mpz_root(gmpnum_result1, gmpnum_a, (unsigned long) nth);
|
||||
mpz_pow_ui(gmpnum_result2, gmpnum_result1, (unsigned long) nth);
|
||||
mpz_sub(gmpnum_result2, gmpnum_a, gmpnum_result2);
|
||||
mpz_abs(gmpnum_result2, gmpnum_result2);
|
||||
#endif
|
||||
|
||||
FREE_GMP_TEMP(temp_a);
|
||||
|
@ -56,7 +56,7 @@ array(2) {
|
||||
[1]=>
|
||||
object(GMP)#%d (1) {
|
||||
["num"]=>
|
||||
string(2) "36"
|
||||
string(3) "-36"
|
||||
}
|
||||
}
|
||||
array(2) {
|
||||
|
Loading…
Reference in New Issue
Block a user