1--TEST--
2round() with different rounding modes for zeros
3--FILE--
4<?php
5$modes = [
6    "PHP_ROUND_HALF_UP" => PHP_ROUND_HALF_UP,
7    "PHP_ROUND_HALF_DOWN" => PHP_ROUND_HALF_DOWN,
8    "PHP_ROUND_HALF_EVEN" => PHP_ROUND_HALF_EVEN,
9    "PHP_ROUND_HALF_ODD" => PHP_ROUND_HALF_ODD,
10    "PositiveInfinity" => RoundingMode::PositiveInfinity,
11    "NegativeInfinity" => RoundingMode::NegativeInfinity,
12    "TowardsZero" => RoundingMode::TowardsZero,
13    "AwayFromZero" => RoundingMode::AwayFromZero,
14];
15
16$precisions = [-1, 0, 1, 2];
17
18foreach ($modes as $modeKey => $mode) {
19    echo "mode: $modeKey\n";
20    foreach ($precisions as $precision) {
21        echo "\tprecision: $precision\n";
22        echo "\t\t     0 => " . round(0, $precision, $mode) . "\n";
23        echo "\t\t    -0 => " . round(-0, $precision, $mode) . "\n";
24        echo "\t\t   0.0 => " . round(0.0, $precision, $mode) . "\n";
25        echo "\t\t  -0.0 => " . round(-0.0, $precision, $mode) . "\n";
26        echo "\n";
27    }
28}
29
30?>
31--EXPECT--
32mode: PHP_ROUND_HALF_UP
33	precision: -1
34		     0 => 0
35		    -0 => 0
36		   0.0 => 0
37		  -0.0 => -0
38
39	precision: 0
40		     0 => 0
41		    -0 => 0
42		   0.0 => 0
43		  -0.0 => -0
44
45	precision: 1
46		     0 => 0
47		    -0 => 0
48		   0.0 => 0
49		  -0.0 => -0
50
51	precision: 2
52		     0 => 0
53		    -0 => 0
54		   0.0 => 0
55		  -0.0 => -0
56
57mode: PHP_ROUND_HALF_DOWN
58	precision: -1
59		     0 => 0
60		    -0 => 0
61		   0.0 => 0
62		  -0.0 => -0
63
64	precision: 0
65		     0 => 0
66		    -0 => 0
67		   0.0 => 0
68		  -0.0 => -0
69
70	precision: 1
71		     0 => 0
72		    -0 => 0
73		   0.0 => 0
74		  -0.0 => -0
75
76	precision: 2
77		     0 => 0
78		    -0 => 0
79		   0.0 => 0
80		  -0.0 => -0
81
82mode: PHP_ROUND_HALF_EVEN
83	precision: -1
84		     0 => 0
85		    -0 => 0
86		   0.0 => 0
87		  -0.0 => -0
88
89	precision: 0
90		     0 => 0
91		    -0 => 0
92		   0.0 => 0
93		  -0.0 => -0
94
95	precision: 1
96		     0 => 0
97		    -0 => 0
98		   0.0 => 0
99		  -0.0 => -0
100
101	precision: 2
102		     0 => 0
103		    -0 => 0
104		   0.0 => 0
105		  -0.0 => -0
106
107mode: PHP_ROUND_HALF_ODD
108	precision: -1
109		     0 => 0
110		    -0 => 0
111		   0.0 => 0
112		  -0.0 => -0
113
114	precision: 0
115		     0 => 0
116		    -0 => 0
117		   0.0 => 0
118		  -0.0 => -0
119
120	precision: 1
121		     0 => 0
122		    -0 => 0
123		   0.0 => 0
124		  -0.0 => -0
125
126	precision: 2
127		     0 => 0
128		    -0 => 0
129		   0.0 => 0
130		  -0.0 => -0
131
132mode: PositiveInfinity
133	precision: -1
134		     0 => 0
135		    -0 => 0
136		   0.0 => 0
137		  -0.0 => -0
138
139	precision: 0
140		     0 => 0
141		    -0 => 0
142		   0.0 => 0
143		  -0.0 => -0
144
145	precision: 1
146		     0 => 0
147		    -0 => 0
148		   0.0 => 0
149		  -0.0 => -0
150
151	precision: 2
152		     0 => 0
153		    -0 => 0
154		   0.0 => 0
155		  -0.0 => -0
156
157mode: NegativeInfinity
158	precision: -1
159		     0 => 0
160		    -0 => 0
161		   0.0 => 0
162		  -0.0 => -0
163
164	precision: 0
165		     0 => 0
166		    -0 => 0
167		   0.0 => 0
168		  -0.0 => -0
169
170	precision: 1
171		     0 => 0
172		    -0 => 0
173		   0.0 => 0
174		  -0.0 => -0
175
176	precision: 2
177		     0 => 0
178		    -0 => 0
179		   0.0 => 0
180		  -0.0 => -0
181
182mode: TowardsZero
183	precision: -1
184		     0 => 0
185		    -0 => 0
186		   0.0 => 0
187		  -0.0 => -0
188
189	precision: 0
190		     0 => 0
191		    -0 => 0
192		   0.0 => 0
193		  -0.0 => -0
194
195	precision: 1
196		     0 => 0
197		    -0 => 0
198		   0.0 => 0
199		  -0.0 => -0
200
201	precision: 2
202		     0 => 0
203		    -0 => 0
204		   0.0 => 0
205		  -0.0 => -0
206
207mode: AwayFromZero
208	precision: -1
209		     0 => 0
210		    -0 => 0
211		   0.0 => 0
212		  -0.0 => -0
213
214	precision: 0
215		     0 => 0
216		    -0 => 0
217		   0.0 => 0
218		  -0.0 => -0
219
220	precision: 1
221		     0 => 0
222		    -0 => 0
223		   0.0 => 0
224		  -0.0 => -0
225
226	precision: 2
227		     0 => 0
228		    -0 => 0
229		   0.0 => 0
230		  -0.0 => -0
231