[php-src] master: Merge branch 'PHP-8.5'
| From: | Saki Takamachi | Date: | Sat, 05 Sep 2026 01:46:31 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141077@lists.php.net to get a copy of this message | ||
Author: Saki Takamachi (SakiTakamachi)
Date: 2026-09-05T10:46:03+09:00
Commit: https://github.com/php/php-src/commit/01970adcf3d6e87844bb10e6720a5be9e5d403f4
Raw diff: https://github.com/php/php-src/commit/01970adcf3d6e87844bb10e6720a5be9e5d403f4.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
ext/standard Fix round() for large integral doubles (#22461)
Changed paths:
A ext/standard/tests/math/gh22410.phpt
M ext/standard/math.c
Diff:
diff --git a/ext/standard/math.c b/ext/standard/math.c
index e13f153f63e2..20286870c7c9 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -170,6 +170,10 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
return value;
}
+ if (places == 0 && value == trunc(value)) {
+ return value;
+ }
+
places = places < INT_MIN+1 ? INT_MIN+1 : places;
exponent = php_intpow10(abs(places));
diff --git a/ext/standard/tests/math/gh22410.phpt b/ext/standard/tests/math/gh22410.phpt
new file mode 100644
index 000000000000..db2e92c3e6d9
--- /dev/null
+++ b/ext/standard/tests/math/gh22410.phpt
@@ -0,0 +1,14 @@
+--TEST--
+gh-22410: round() preserves integral doubles
+--FILE--
+<?php
+var_dump(round(1.0));
+var_dump(round(-1.0));
+var_dump(round((float) 9003241321073828));
+var_dump(round((float) -9003241321073828));
+?>
+--EXPECT--
+float(1)
+float(-1)
+float(9003241321073828)
+float(-9003241321073828)