1--TEST--
2Test sprintf() function : usage variations - scientific formats with integer values
3--FILE--
4<?php
5echo "*** Testing sprintf() : scientific formats with integer values ***\n";
6
7// array of integer 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// array of scientific formats
30$scientific_formats = array(
31  "%e", "%le", " %e", "%e ",
32  "\t%e", "\n%e", "%4e", "%30e",
33);
34
35$count = 1;
36foreach($integer_values as $integer_value) {
37  echo "\n-- Iteration $count --\n";
38
39  foreach($scientific_formats as $format) {
40    var_dump( sprintf($format, $integer_value) );
41  }
42  $count++;
43};
44
45echo "Done";
46?>
47--EXPECT--
48*** Testing sprintf() : scientific formats with integer values ***
49
50-- Iteration 1 --
51string(11) "0.000000e+0"
52string(11) "0.000000e+0"
53string(12) " 0.000000e+0"
54string(12) "0.000000e+0 "
55string(12) "	0.000000e+0"
56string(12) "
570.000000e+0"
58string(11) "0.000000e+0"
59string(30) "                   0.000000e+0"
60
61-- Iteration 2 --
62string(11) "1.000000e+0"
63string(11) "1.000000e+0"
64string(12) " 1.000000e+0"
65string(12) "1.000000e+0 "
66string(12) "	1.000000e+0"
67string(12) "
681.000000e+0"
69string(11) "1.000000e+0"
70string(30) "                   1.000000e+0"
71
72-- Iteration 3 --
73string(12) "-1.000000e+0"
74string(12) "-1.000000e+0"
75string(13) " -1.000000e+0"
76string(13) "-1.000000e+0 "
77string(13) "	-1.000000e+0"
78string(13) "
79-1.000000e+0"
80string(12) "-1.000000e+0"
81string(30) "                  -1.000000e+0"
82
83-- Iteration 4 --
84string(12) "-2.147484e+9"
85string(12) "-2.147484e+9"
86string(13) " -2.147484e+9"
87string(13) "-2.147484e+9 "
88string(13) "	-2.147484e+9"
89string(13) "
90-2.147484e+9"
91string(12) "-2.147484e+9"
92string(30) "                  -2.147484e+9"
93
94-- Iteration 5 --
95string(12) "-2.147484e+9"
96string(12) "-2.147484e+9"
97string(13) " -2.147484e+9"
98string(13) "-2.147484e+9 "
99string(13) "	-2.147484e+9"
100string(13) "
101-2.147484e+9"
102string(12) "-2.147484e+9"
103string(30) "                  -2.147484e+9"
104
105-- Iteration 6 --
106string(11) "2.147484e+9"
107string(11) "2.147484e+9"
108string(12) " 2.147484e+9"
109string(12) "2.147484e+9 "
110string(12) "	2.147484e+9"
111string(12) "
1122.147484e+9"
113string(11) "2.147484e+9"
114string(30) "                   2.147484e+9"
115
116-- Iteration 7 --
117string(11) "2.147484e+9"
118string(11) "2.147484e+9"
119string(12) " 2.147484e+9"
120string(12) "2.147484e+9 "
121string(12) "	2.147484e+9"
122string(12) "
1232.147484e+9"
124string(11) "2.147484e+9"
125string(30) "                   2.147484e+9"
126
127-- Iteration 8 --
128string(11) "4.667000e+3"
129string(11) "4.667000e+3"
130string(12) " 4.667000e+3"
131string(12) "4.667000e+3 "
132string(12) "	4.667000e+3"
133string(12) "
1344.667000e+3"
135string(11) "4.667000e+3"
136string(30) "                   4.667000e+3"
137
138-- Iteration 9 --
139string(11) "4.779000e+3"
140string(11) "4.779000e+3"
141string(12) " 4.779000e+3"
142string(12) "4.779000e+3 "
143string(12) "	4.779000e+3"
144string(12) "
1454.779000e+3"
146string(11) "4.779000e+3"
147string(30) "                   4.779000e+3"
148
149-- Iteration 10 --
150string(11) "4.095000e+3"
151string(11) "4.095000e+3"
152string(12) " 4.095000e+3"
153string(12) "4.095000e+3 "
154string(12) "	4.095000e+3"
155string(12) "
1564.095000e+3"
157string(11) "4.095000e+3"
158string(30) "                   4.095000e+3"
159
160-- Iteration 11 --
161string(11) "2.500000e+2"
162string(11) "2.500000e+2"
163string(12) " 2.500000e+2"
164string(12) "2.500000e+2 "
165string(12) "	2.500000e+2"
166string(12) "
1672.500000e+2"
168string(11) "2.500000e+2"
169string(30) "                   2.500000e+2"
170
171-- Iteration 12 --
172string(12) "-2.147484e+9"
173string(12) "-2.147484e+9"
174string(13) " -2.147484e+9"
175string(13) "-2.147484e+9 "
176string(13) "	-2.147484e+9"
177string(13) "
178-2.147484e+9"
179string(12) "-2.147484e+9"
180string(30) "                  -2.147484e+9"
181
182-- Iteration 13 --
183string(11) "2.147484e+9"
184string(11) "2.147484e+9"
185string(12) " 2.147484e+9"
186string(12) "2.147484e+9 "
187string(12) "	2.147484e+9"
188string(12) "
1892.147484e+9"
190string(11) "2.147484e+9"
191string(30) "                   2.147484e+9"
192
193-- Iteration 14 --
194string(11) "2.147484e+9"
195string(11) "2.147484e+9"
196string(12) " 2.147484e+9"
197string(12) "2.147484e+9 "
198string(12) "	2.147484e+9"
199string(12) "
2002.147484e+9"
201string(11) "2.147484e+9"
202string(30) "                   2.147484e+9"
203
204-- Iteration 15 --
205string(11) "8.300000e+1"
206string(11) "8.300000e+1"
207string(12) " 8.300000e+1"
208string(12) "8.300000e+1 "
209string(12) "	8.300000e+1"
210string(12) "
2118.300000e+1"
212string(11) "8.300000e+1"
213string(30) "                   8.300000e+1"
214
215-- Iteration 16 --
216string(11) "1.000000e+0"
217string(11) "1.000000e+0"
218string(12) " 1.000000e+0"
219string(12) "1.000000e+0 "
220string(12) "	1.000000e+0"
221string(12) "
2221.000000e+0"
223string(11) "1.000000e+0"
224string(30) "                   1.000000e+0"
225
226-- Iteration 17 --
227string(12) "-2.147484e+9"
228string(12) "-2.147484e+9"
229string(13) " -2.147484e+9"
230string(13) "-2.147484e+9 "
231string(13) "	-2.147484e+9"
232string(13) "
233-2.147484e+9"
234string(12) "-2.147484e+9"
235string(30) "                  -2.147484e+9"
236
237-- Iteration 18 --
238string(11) "2.147484e+9"
239string(11) "2.147484e+9"
240string(12) " 2.147484e+9"
241string(12) "2.147484e+9 "
242string(12) "	2.147484e+9"
243string(12) "
2442.147484e+9"
245string(11) "2.147484e+9"
246string(30) "                   2.147484e+9"
247Done
248