1--TEST--
2Test round() - basic function test for round()
3--INI--
4precision=14
5--FILE--
6<?php
7/* Prototype  : float round  ( float $val  [, int $precision  ] )
8 * Description: Returns the rounded value of val  to specified precision (number of digits
9 * after the decimal point)
10 * Source code: ext/standard/math.c
11 */
12
13echo "*** Testing round() : basic functionality ***\n";
14
15$values = array(123456789,
16				123.456789,
17				-4.5679123,
18				1.23E4,
19				-4.567E3,
20				0x234567,
21				067777777,
22				"1.234567",
23				"2.3456789e8",
24				"0x1234CDEF");
25
26$precision = array(2,
27				8,
28				0x3,
29				04,
30				3.6,
31				"2",
32				"0x03",
33				"04",
34				"3.6",
35				"2.1e1",
36				null,
37				true,
38				false);
39
40for ($i = 0; $i < count($values); $i++) {
41	echo "round: $values[$i]\n";
42	for ($j = 0; $j < count($precision); $j++) {
43		$res = round($values[$i], $precision[$j]);
44		echo "...with precision $precision[$j]-> ";
45		var_dump($res);
46	}
47}
48?>
49===Done===
50--EXPECTF--
51*** Testing round() : basic functionality ***
52round: 123456789
53...with precision 2-> float(123456789)
54...with precision 8-> float(123456789)
55...with precision 3-> float(123456789)
56...with precision 4-> float(123456789)
57...with precision 3.6-> float(123456789)
58...with precision 2-> float(123456789)
59...with precision 0x03-> float(123456789)
60...with precision 04-> float(123456789)
61...with precision 3.6-> float(123456789)
62...with precision 2.1e1-> float(123456789)
63...with precision -> float(123456789)
64...with precision 1-> float(123456789)
65...with precision -> float(123456789)
66round: 123.456789
67...with precision 2-> float(123.46)
68...with precision 8-> float(123.456789)
69...with precision 3-> float(123.457)
70...with precision 4-> float(123.4568)
71...with precision 3.6-> float(123.457)
72...with precision 2-> float(123.46)
73...with precision 0x03-> float(123.457)
74...with precision 04-> float(123.4568)
75...with precision 3.6-> float(123.457)
76...with precision 2.1e1-> float(123.456789)
77...with precision -> float(123)
78...with precision 1-> float(123.5)
79...with precision -> float(123)
80round: -4.5679123
81...with precision 2-> float(-4.57)
82...with precision 8-> float(-4.5679123)
83...with precision 3-> float(-4.568)
84...with precision 4-> float(-4.5679)
85...with precision 3.6-> float(-4.568)
86...with precision 2-> float(-4.57)
87...with precision 0x03-> float(-4.568)
88...with precision 04-> float(-4.5679)
89...with precision 3.6-> float(-4.568)
90...with precision 2.1e1-> float(-4.5679123)
91...with precision -> float(-5)
92...with precision 1-> float(-4.6)
93...with precision -> float(-5)
94round: 12300
95...with precision 2-> float(12300)
96...with precision 8-> float(12300)
97...with precision 3-> float(12300)
98...with precision 4-> float(12300)
99...with precision 3.6-> float(12300)
100...with precision 2-> float(12300)
101...with precision 0x03-> float(12300)
102...with precision 04-> float(12300)
103...with precision 3.6-> float(12300)
104...with precision 2.1e1-> float(12300)
105...with precision -> float(12300)
106...with precision 1-> float(12300)
107...with precision -> float(12300)
108round: -4567
109...with precision 2-> float(-4567)
110...with precision 8-> float(-4567)
111...with precision 3-> float(-4567)
112...with precision 4-> float(-4567)
113...with precision 3.6-> float(-4567)
114...with precision 2-> float(-4567)
115...with precision 0x03-> float(-4567)
116...with precision 04-> float(-4567)
117...with precision 3.6-> float(-4567)
118...with precision 2.1e1-> float(-4567)
119...with precision -> float(-4567)
120...with precision 1-> float(-4567)
121...with precision -> float(-4567)
122round: 2311527
123...with precision 2-> float(2311527)
124...with precision 8-> float(2311527)
125...with precision 3-> float(2311527)
126...with precision 4-> float(2311527)
127...with precision 3.6-> float(2311527)
128...with precision 2-> float(2311527)
129...with precision 0x03-> float(2311527)
130...with precision 04-> float(2311527)
131...with precision 3.6-> float(2311527)
132...with precision 2.1e1-> float(2311527)
133...with precision -> float(2311527)
134...with precision 1-> float(2311527)
135...with precision -> float(2311527)
136round: 14680063
137...with precision 2-> float(14680063)
138...with precision 8-> float(14680063)
139...with precision 3-> float(14680063)
140...with precision 4-> float(14680063)
141...with precision 3.6-> float(14680063)
142...with precision 2-> float(14680063)
143...with precision 0x03-> float(14680063)
144...with precision 04-> float(14680063)
145...with precision 3.6-> float(14680063)
146...with precision 2.1e1-> float(14680063)
147...with precision -> float(14680063)
148...with precision 1-> float(14680063)
149...with precision -> float(14680063)
150round: 1.234567
151...with precision 2-> float(1.23)
152...with precision 8-> float(1.234567)
153...with precision 3-> float(1.235)
154...with precision 4-> float(1.2346)
155...with precision 3.6-> float(1.235)
156...with precision 2-> float(1.23)
157...with precision 0x03-> float(1.235)
158...with precision 04-> float(1.2346)
159...with precision 3.6-> float(1.235)
160...with precision 2.1e1-> float(1.234567)
161...with precision -> float(1)
162...with precision 1-> float(1.2)
163...with precision -> float(1)
164round: 2.3456789e8
165...with precision 2-> float(234567890)
166...with precision 8-> float(234567890)
167...with precision 3-> float(234567890)
168...with precision 4-> float(234567890)
169...with precision 3.6-> float(234567890)
170...with precision 2-> float(234567890)
171...with precision 0x03-> float(234567890)
172...with precision 04-> float(234567890)
173...with precision 3.6-> float(234567890)
174...with precision 2.1e1-> float(234567890)
175...with precision -> float(234567890)
176...with precision 1-> float(234567890)
177...with precision -> float(234567890)
178round: 0x1234CDEF
179...with precision 2-> float(305450479)
180...with precision 8-> float(305450479)
181...with precision 3-> float(305450479)
182...with precision 4-> float(305450479)
183...with precision 3.6-> float(305450479)
184...with precision 2-> float(305450479)
185...with precision 0x03-> float(305450479)
186...with precision 04-> float(305450479)
187...with precision 3.6-> float(305450479)
188...with precision 2.1e1-> float(305450479)
189...with precision -> float(305450479)
190...with precision 1-> float(305450479)
191...with precision -> float(305450479)
192===Done===