1--TEST--
2Test sprintf() function : usage variations - float formats with integer values
3--FILE--
4<?php
5echo "*** Testing sprintf() : float formats with integer values ***\n";
6
7// array of int type values
8$integer_values = array (
9  0,
10  1,
11  -1,
12  -2147483648, // max negative integer value
13  -2147483647,
14  2147483647,  // max positive integer value
15  2147483640,
16  0x123B,      // integer as hexadecimal
17  0x12ab,
18  0Xfff,
19  0XFA,
20  -0x80000000, // max negative integer as hexadecimal
21  0x7fffffff,  // max positive integer as hexadecimal
22  0x7FFFFFFF,  // max positive integer as hexadecimal
23  0123,        // integer as octal
24  01,       // should be quivalent to octal 1
25  -020000000000, // max negative integer as octal
26  017777777777  // max positive integer as octal
27);
28
29// various float formats
30$float_formats = array(
31  "%f", "%lf", " %f", "%f ",
32  "\t%f", "\n%f", "%4f", "%30f",
33);
34
35$count = 1;
36foreach($integer_values as $int_value) {
37  echo "\n-- Iteration $count --\n";
38
39  foreach($float_formats as $format) {
40    // with two arguments
41    var_dump( sprintf($format, $int_value) );
42  }
43  $count++;
44};
45
46echo "Done";
47?>
48--EXPECT--
49*** Testing sprintf() : float formats with integer values ***
50
51-- Iteration 1 --
52string(8) "0.000000"
53string(8) "0.000000"
54string(9) " 0.000000"
55string(9) "0.000000 "
56string(9) "	0.000000"
57string(9) "
580.000000"
59string(8) "0.000000"
60string(30) "                      0.000000"
61
62-- Iteration 2 --
63string(8) "1.000000"
64string(8) "1.000000"
65string(9) " 1.000000"
66string(9) "1.000000 "
67string(9) "	1.000000"
68string(9) "
691.000000"
70string(8) "1.000000"
71string(30) "                      1.000000"
72
73-- Iteration 3 --
74string(9) "-1.000000"
75string(9) "-1.000000"
76string(10) " -1.000000"
77string(10) "-1.000000 "
78string(10) "	-1.000000"
79string(10) "
80-1.000000"
81string(9) "-1.000000"
82string(30) "                     -1.000000"
83
84-- Iteration 4 --
85string(18) "-2147483648.000000"
86string(18) "-2147483648.000000"
87string(19) " -2147483648.000000"
88string(19) "-2147483648.000000 "
89string(19) "	-2147483648.000000"
90string(19) "
91-2147483648.000000"
92string(18) "-2147483648.000000"
93string(30) "            -2147483648.000000"
94
95-- Iteration 5 --
96string(18) "-2147483647.000000"
97string(18) "-2147483647.000000"
98string(19) " -2147483647.000000"
99string(19) "-2147483647.000000 "
100string(19) "	-2147483647.000000"
101string(19) "
102-2147483647.000000"
103string(18) "-2147483647.000000"
104string(30) "            -2147483647.000000"
105
106-- Iteration 6 --
107string(17) "2147483647.000000"
108string(17) "2147483647.000000"
109string(18) " 2147483647.000000"
110string(18) "2147483647.000000 "
111string(18) "	2147483647.000000"
112string(18) "
1132147483647.000000"
114string(17) "2147483647.000000"
115string(30) "             2147483647.000000"
116
117-- Iteration 7 --
118string(17) "2147483640.000000"
119string(17) "2147483640.000000"
120string(18) " 2147483640.000000"
121string(18) "2147483640.000000 "
122string(18) "	2147483640.000000"
123string(18) "
1242147483640.000000"
125string(17) "2147483640.000000"
126string(30) "             2147483640.000000"
127
128-- Iteration 8 --
129string(11) "4667.000000"
130string(11) "4667.000000"
131string(12) " 4667.000000"
132string(12) "4667.000000 "
133string(12) "	4667.000000"
134string(12) "
1354667.000000"
136string(11) "4667.000000"
137string(30) "                   4667.000000"
138
139-- Iteration 9 --
140string(11) "4779.000000"
141string(11) "4779.000000"
142string(12) " 4779.000000"
143string(12) "4779.000000 "
144string(12) "	4779.000000"
145string(12) "
1464779.000000"
147string(11) "4779.000000"
148string(30) "                   4779.000000"
149
150-- Iteration 10 --
151string(11) "4095.000000"
152string(11) "4095.000000"
153string(12) " 4095.000000"
154string(12) "4095.000000 "
155string(12) "	4095.000000"
156string(12) "
1574095.000000"
158string(11) "4095.000000"
159string(30) "                   4095.000000"
160
161-- Iteration 11 --
162string(10) "250.000000"
163string(10) "250.000000"
164string(11) " 250.000000"
165string(11) "250.000000 "
166string(11) "	250.000000"
167string(11) "
168250.000000"
169string(10) "250.000000"
170string(30) "                    250.000000"
171
172-- Iteration 12 --
173string(18) "-2147483648.000000"
174string(18) "-2147483648.000000"
175string(19) " -2147483648.000000"
176string(19) "-2147483648.000000 "
177string(19) "	-2147483648.000000"
178string(19) "
179-2147483648.000000"
180string(18) "-2147483648.000000"
181string(30) "            -2147483648.000000"
182
183-- Iteration 13 --
184string(17) "2147483647.000000"
185string(17) "2147483647.000000"
186string(18) " 2147483647.000000"
187string(18) "2147483647.000000 "
188string(18) "	2147483647.000000"
189string(18) "
1902147483647.000000"
191string(17) "2147483647.000000"
192string(30) "             2147483647.000000"
193
194-- Iteration 14 --
195string(17) "2147483647.000000"
196string(17) "2147483647.000000"
197string(18) " 2147483647.000000"
198string(18) "2147483647.000000 "
199string(18) "	2147483647.000000"
200string(18) "
2012147483647.000000"
202string(17) "2147483647.000000"
203string(30) "             2147483647.000000"
204
205-- Iteration 15 --
206string(9) "83.000000"
207string(9) "83.000000"
208string(10) " 83.000000"
209string(10) "83.000000 "
210string(10) "	83.000000"
211string(10) "
21283.000000"
213string(9) "83.000000"
214string(30) "                     83.000000"
215
216-- Iteration 16 --
217string(8) "1.000000"
218string(8) "1.000000"
219string(9) " 1.000000"
220string(9) "1.000000 "
221string(9) "	1.000000"
222string(9) "
2231.000000"
224string(8) "1.000000"
225string(30) "                      1.000000"
226
227-- Iteration 17 --
228string(18) "-2147483648.000000"
229string(18) "-2147483648.000000"
230string(19) " -2147483648.000000"
231string(19) "-2147483648.000000 "
232string(19) "	-2147483648.000000"
233string(19) "
234-2147483648.000000"
235string(18) "-2147483648.000000"
236string(30) "            -2147483648.000000"
237
238-- Iteration 18 --
239string(17) "2147483647.000000"
240string(17) "2147483647.000000"
241string(18) " 2147483647.000000"
242string(18) "2147483647.000000 "
243string(18) "	2147483647.000000"
244string(18) "
2452147483647.000000"
246string(17) "2147483647.000000"
247string(30) "             2147483647.000000"
248Done
249