com php-src: Fixed bug #46564: NEWS UPGRADING ext/bcmath/bcmath.c ext/bcmath/tests/bcmod.phpt
| From: | Nikita Popov | Date: | Sat, 07 Jan 2017 18:10:31 +0000 |
| Subject: | com php-src: Fixed bug #46564: NEWS UPGRADING ext/bcmath/bcmath.c ext/bcmath/tests/bcmod.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96607@lists.php.net to get a copy of this message | ||
Commit: 90dcbbe3cb9aed197cbb854afe2eed0f6479a95a
Author: Libor M <liborm85@gmail.com> Sat, 17 Oct 2015 08:09:16 +0200
Committer: Nikita Popov <nikic@php.net> Sat, 7 Jan 2017 19:10:31 +0100
Parents: 00062d2ea8a433582d96e37772fa8928c8454938
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=90dcbbe3cb9aed197cbb854afe2eed0f6479a95a
Log:
Fixed bug #46564
bcmod() no longer truncates fractionals to integers. This matches
the behavior of fmod(). It also matches the behavior of bcpowmod().
It also matches the behavior of bcmod() in HHVM.
Bugs:
https://bugs.php.net/46564
Changed paths:
M NEWS
M UPGRADING
M ext/bcmath/bcmath.c
M ext/bcmath/tests/bcmod.phpt
Diff:
diff --git a/NEWS b/NEWS
index a9f9211..cc1bd15 100644
--- a/NEWS
+++ b/NEWS
@@ -2,9 +2,6 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.2
-- Calendar:
- . Fix integer overflows (Joshua Rogers)
-
- Core:
. Removed IS_TYPE_IMMUTABLE (it's the same as COPYABLE & !REFCOUNTED). (Dmitry)
. Removed the sql.safe_mode directive. (Kalle)
@@ -26,6 +23,12 @@ PHP NEWS
. Raised minimum supported Windows versions to Windows 7/Server 2008 R2.
(Anatol)
+- BCMath:
+ . Fixed bug #46564 (bcmod truncates fractionals). (liborm85)
+
+- Calendar:
+ . Fix integer overflows (Joshua Rogers)
+
- Date:
. Fixed bug #69587 (DateInterval properties and isset). (jhdxr)
diff --git a/UPGRADING b/UPGRADING
index b3c1d19..7766d4e 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -37,6 +37,11 @@ PHP 7.2 UPGRADE NOTES
property names would become inaccessible string keys.
. Minimum supported Windows versions are Windows 7/Server 2008 R2.
+- BCMath:
+ . The bcmod() function no longer truncates fractional numbers to integers. As
+ such, its behavior now follows fmod() rather than the
% operator.. For
+ example bcmod('4', '3.5') now returns '0.5' instead
of '1'.
+
- PCRE:
. preg_match() and other PCRE functions now distinguish between unmatched
subpatterns and empty matches by reporting NULL and "" (empty string),
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 300d88b..e8b87dc 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -403,8 +403,8 @@ PHP_FUNCTION(bcmod)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
- bc_str2num(&first, ZSTR_VAL(left), 0);
- bc_str2num(&second, ZSTR_VAL(right), 0);
+ php_str2num(&first, ZSTR_VAL(left));
+ php_str2num(&second, ZSTR_VAL(right));
switch (bc_modulo(first, second, &result, 0)) {
case 0:
diff --git a/ext/bcmath/tests/bcmod.phpt b/ext/bcmath/tests/bcmod.phpt
index 1d7be48..5657e02 100644
--- a/ext/bcmath/tests/bcmod.phpt
+++ b/ext/bcmath/tests/bcmod.phpt
@@ -9,8 +9,12 @@ bcmath..scale=0
echo bcmod("11", "2"),"\n";
echo bcmod("-1", "5"),"\n";
echo bcmod("8728932001983192837219398127471",
"1928372132132819737213"),"\n";
+echo bcmod("3.5", "4"),"\n";
+echo bcmod("1071", "357.5"),"\n";
?>
--EXPECT--
1
-1
1459434331351930289678
+3.5
+356.0