mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: ext/bcmath: Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0)
This commit is contained in:
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)
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
*************************************************************************/
|
||||
|
||||
#include "bcmath.h"
|
||||
#include "private.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/* Raise BASE to the EXPO power, reduced modulo MOD. The result is placed in RESULT. */
|
||||
@@ -67,7 +68,7 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
|
||||
|
||||
/* 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);
|
||||
} else {
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user