[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Sat, 05 Sep 2026 01:46:31 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141076@lists.php.net to get a copy of this message
Author: Saki Takamachi (SakiTakamachi) Date: 2026-09-05T10:45:50+09:00 Commit: https://github.com/php/php-src/commit/67d1476d4d8015c7a7ddf3221eb062c423869818 Raw diff: https://github.com/php/php-src/commit/67d1476d4d8015c7a7ddf3221eb062c423869818.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/standard Fix round() for large integral doubles (#22461) Changed paths: A ext/standard/tests/math/gh22410.phpt M NEWS M ext/standard/math.c Diff: diff --git a/NEWS b/NEWS index 699339680c41..83a6f7c6ed8b 100644 --- a/NEWS +++ b/NEWS @@ -92,6 +92,8 @@ PHP NEWS . Fixed an out-of-bounds read when following a redirect response with an empty Location header. (iliaal) . Fixed read buffer compaction in php_stream_filter_flush(). (crystarm) + . Fixed bug GH-22410 (Incorrect float behavior with large numbers). + (arshidkv12) - SimpleXML: . Fixed writing to a dimension of the object returned by attributes() not diff --git a/ext/standard/math.c b/ext/standard/math.c index 758b352f90ff..09d982981043 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -172,6 +172,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)

« previous php.cvs (#141076) next »