Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/standard/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,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));
Expand Down
14 changes: 14 additions & 0 deletions ext/standard/tests/math/gh22410.phpt
Original file line number Diff line number Diff line change
@@ -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)
Loading