mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
ext/bcmath: Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0)
This commit is contained in:
parent
ce7ed6e040
commit
709869c8bd
3
NEWS
3
NEWS
@ -7,6 +7,9 @@ PHP NEWS
|
||||
. Fixed bug GH-12814 (max_execution_time reached too early on MacOS 14
|
||||
when running on Apple Silicon). (Manuel Kress)
|
||||
|
||||
- BCMatch:
|
||||
. Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0). (Girgias)
|
||||
|
||||
- Curl:
|
||||
. Fixed bug GH-14307 (Test curl_basic_024 fails with curl 8.8.0). (nielsdos)
|
||||
|
||||
|
@ -81,7 +81,7 @@ zend_result bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, i
|
||||
|
||||
/* Do the calculation. */
|
||||
rscale = MAX(scale, power->n_scale);
|
||||
if ( !bc_compare(modulus, BCG(_one_)) )
|
||||
if ( !_bc_do_compare(modulus, BCG(_one_), false, false) )
|
||||
{
|
||||
bc_free_num (&temp);
|
||||
temp = bc_new_num (1, scale);
|
||||
|
16
ext/bcmath/tests/bcpowmod_with_mod_1.phpt
Normal file
16
ext/bcmath/tests/bcpowmod_with_mod_1.phpt
Normal file
@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
bcpowmod() must return 0 when mod is +1 or -1
|
||||
--EXTENSIONS--
|
||||
bcmath
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(bcpowmod(5, 0, 1));
|
||||
var_dump(bcpowmod(5, 0, 1, 3));
|
||||
var_dump(bcpowmod(5, 0, -1));
|
||||
var_dump(bcpowmod(5, 0, -1, 3));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "0"
|
||||
string(5) "0.000"
|
||||
string(1) "0"
|
||||
string(5) "0.000"
|
Loading…
Reference in New Issue
Block a user