Skip to content

Fix round() tests for different modes #12049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2023
Merged
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
18 changes: 9 additions & 9 deletions ext/standard/tests/math/round_modes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ foreach ($modes as $modeKey => $mode) {
foreach ($precisions as $precision) {
echo "\tprecision: $precision\n";
foreach ($numbers as $number) {
$result = round($number, $precision);
$result = round($number, $precision, $mode);
echo "\t\t" .
str_pad($number, 7, " ", STR_PAD_LEFT) .
" => $result\n";
Expand Down Expand Up @@ -105,10 +105,10 @@ mode: PHP_ROUND_HALF_UP

mode: PHP_ROUND_HALF_DOWN
precision: 0
2.5 => 3
-2.5 => -3
3.5 => 4
-3.5 => -4
2.5 => 2
-2.5 => -2
3.5 => 3
-3.5 => -3
7 => 7
-7 => -7
0.61 => 1
Expand Down Expand Up @@ -166,8 +166,8 @@ mode: PHP_ROUND_HALF_DOWN

mode: PHP_ROUND_HALF_EVEN
precision: 0
2.5 => 3
-2.5 => -3
2.5 => 2
-2.5 => -2
3.5 => 4
-3.5 => -4
7 => 7
Expand Down Expand Up @@ -229,8 +229,8 @@ mode: PHP_ROUND_HALF_ODD
precision: 0
2.5 => 3
-2.5 => -3
3.5 => 4
-3.5 => -4
3.5 => 3
-3.5 => -3
7 => 7
-7 => -7
0.61 => 1
Expand Down