1--TEST--
2Test round() - basic function test for round()
3--INI--
4precision=14
5--FILE--
6<?php
7echo "*** Testing round() : basic functionality ***\n";
8
9$values = array(123456789,
10                123.456789,
11                -4.5679123,
12                1.23E4,
13                -4.567E3,
14                0x234567,
15                067777777,
16                "1.234567",
17                "2.3456789e8");
18
19$precision = array(2,
20                8,
21                0x3,
22                04,
23                3.6,
24                "2",
25                "04",
26                "3.6",
27                "2.1e1",
28                null,
29                true,
30                false);
31
32for ($i = 0; $i < count($values); $i++) {
33    echo "round: $values[$i]\n";
34    for ($j = 0; $j < count($precision); $j++) {
35        $res = round($values[$i], $precision[$j]);
36        echo "...with precision $precision[$j]-> ";
37        var_dump($res);
38    }
39}
40?>
41--EXPECT--
42*** Testing round() : basic functionality ***
43round: 123456789
44...with precision 2-> float(123456789)
45...with precision 8-> float(123456789)
46...with precision 3-> float(123456789)
47...with precision 4-> float(123456789)
48...with precision 3.6-> float(123456789)
49...with precision 2-> float(123456789)
50...with precision 04-> float(123456789)
51...with precision 3.6-> float(123456789)
52...with precision 2.1e1-> float(123456789)
53...with precision -> float(123456789)
54...with precision 1-> float(123456789)
55...with precision -> float(123456789)
56round: 123.456789
57...with precision 2-> float(123.46)
58...with precision 8-> float(123.456789)
59...with precision 3-> float(123.457)
60...with precision 4-> float(123.4568)
61...with precision 3.6-> float(123.457)
62...with precision 2-> float(123.46)
63...with precision 04-> float(123.4568)
64...with precision 3.6-> float(123.457)
65...with precision 2.1e1-> float(123.456789)
66...with precision -> float(123)
67...with precision 1-> float(123.5)
68...with precision -> float(123)
69round: -4.5679123
70...with precision 2-> float(-4.57)
71...with precision 8-> float(-4.5679123)
72...with precision 3-> float(-4.568)
73...with precision 4-> float(-4.5679)
74...with precision 3.6-> float(-4.568)
75...with precision 2-> float(-4.57)
76...with precision 04-> float(-4.5679)
77...with precision 3.6-> float(-4.568)
78...with precision 2.1e1-> float(-4.5679123)
79...with precision -> float(-5)
80...with precision 1-> float(-4.6)
81...with precision -> float(-5)
82round: 12300
83...with precision 2-> float(12300)
84...with precision 8-> float(12300)
85...with precision 3-> float(12300)
86...with precision 4-> float(12300)
87...with precision 3.6-> float(12300)
88...with precision 2-> float(12300)
89...with precision 04-> float(12300)
90...with precision 3.6-> float(12300)
91...with precision 2.1e1-> float(12300)
92...with precision -> float(12300)
93...with precision 1-> float(12300)
94...with precision -> float(12300)
95round: -4567
96...with precision 2-> float(-4567)
97...with precision 8-> float(-4567)
98...with precision 3-> float(-4567)
99...with precision 4-> float(-4567)
100...with precision 3.6-> float(-4567)
101...with precision 2-> float(-4567)
102...with precision 04-> float(-4567)
103...with precision 3.6-> float(-4567)
104...with precision 2.1e1-> float(-4567)
105...with precision -> float(-4567)
106...with precision 1-> float(-4567)
107...with precision -> float(-4567)
108round: 2311527
109...with precision 2-> float(2311527)
110...with precision 8-> float(2311527)
111...with precision 3-> float(2311527)
112...with precision 4-> float(2311527)
113...with precision 3.6-> float(2311527)
114...with precision 2-> float(2311527)
115...with precision 04-> float(2311527)
116...with precision 3.6-> float(2311527)
117...with precision 2.1e1-> float(2311527)
118...with precision -> float(2311527)
119...with precision 1-> float(2311527)
120...with precision -> float(2311527)
121round: 14680063
122...with precision 2-> float(14680063)
123...with precision 8-> float(14680063)
124...with precision 3-> float(14680063)
125...with precision 4-> float(14680063)
126...with precision 3.6-> float(14680063)
127...with precision 2-> float(14680063)
128...with precision 04-> float(14680063)
129...with precision 3.6-> float(14680063)
130...with precision 2.1e1-> float(14680063)
131...with precision -> float(14680063)
132...with precision 1-> float(14680063)
133...with precision -> float(14680063)
134round: 1.234567
135...with precision 2-> float(1.23)
136...with precision 8-> float(1.234567)
137...with precision 3-> float(1.235)
138...with precision 4-> float(1.2346)
139...with precision 3.6-> float(1.235)
140...with precision 2-> float(1.23)
141...with precision 04-> float(1.2346)
142...with precision 3.6-> float(1.235)
143...with precision 2.1e1-> float(1.234567)
144...with precision -> float(1)
145...with precision 1-> float(1.2)
146...with precision -> float(1)
147round: 2.3456789e8
148...with precision 2-> float(234567890)
149...with precision 8-> float(234567890)
150...with precision 3-> float(234567890)
151...with precision 4-> float(234567890)
152...with precision 3.6-> float(234567890)
153...with precision 2-> float(234567890)
154...with precision 04-> float(234567890)
155...with precision 3.6-> float(234567890)
156...with precision 2.1e1-> float(234567890)
157...with precision -> float(234567890)
158...with precision 1-> float(234567890)
159...with precision -> float(234567890)
160