1--TEST--
2Test sprintf() function : usage variations - scientific formats with float values
3--FILE--
4<?php
5echo "*** Testing sprintf() : scientific formats with float values ***\n";
6
7// array of float values
8$float_values = array(
9  -2147483649,
10  2147483648,
11  -0x80000001, // float value, beyond max negative int
12  0x800000001, // float value, beyond max positive int
13  020000000001, // float value, beyond max positive int
14  -020000000001, // float value, beyond max negative int
15  0.0,
16  -0.1,
17  1.0,
18  1e5,
19  -1e5,
20  -1e5,
21  +1e5,
22  1e+5,
23  -1e-5,
24  1E8,
25  -1E9,
26  10.0000000000000000005,
27  10.5e+5
28);
29
30// array of scientific formats
31$scientific_formats = array(
32  "%e", "%le", " %e", "%e ",
33  "\t%e", "\n%e", "%4e", "%30e",
34);
35
36
37$count = 1;
38foreach($float_values as $float_value) {
39  echo "\n-- Iteration $count --\n";
40
41  foreach($scientific_formats as $format) {
42    var_dump( sprintf($format, $float_value) );
43  }
44  $count++;
45};
46
47echo "Done";
48?>
49--EXPECT--
50*** Testing sprintf() : scientific formats with float values ***
51
52-- Iteration 1 --
53string(12) "-2.147484e+9"
54string(12) "-2.147484e+9"
55string(13) " -2.147484e+9"
56string(13) "-2.147484e+9 "
57string(13) "	-2.147484e+9"
58string(13) "
59-2.147484e+9"
60string(12) "-2.147484e+9"
61string(30) "                  -2.147484e+9"
62
63-- Iteration 2 --
64string(11) "2.147484e+9"
65string(11) "2.147484e+9"
66string(12) " 2.147484e+9"
67string(12) "2.147484e+9 "
68string(12) "	2.147484e+9"
69string(12) "
702.147484e+9"
71string(11) "2.147484e+9"
72string(30) "                   2.147484e+9"
73
74-- Iteration 3 --
75string(12) "-2.147484e+9"
76string(12) "-2.147484e+9"
77string(13) " -2.147484e+9"
78string(13) "-2.147484e+9 "
79string(13) "	-2.147484e+9"
80string(13) "
81-2.147484e+9"
82string(12) "-2.147484e+9"
83string(30) "                  -2.147484e+9"
84
85-- Iteration 4 --
86string(12) "3.435974e+10"
87string(12) "3.435974e+10"
88string(13) " 3.435974e+10"
89string(13) "3.435974e+10 "
90string(13) "	3.435974e+10"
91string(13) "
923.435974e+10"
93string(12) "3.435974e+10"
94string(30) "                  3.435974e+10"
95
96-- Iteration 5 --
97string(11) "2.147484e+9"
98string(11) "2.147484e+9"
99string(12) " 2.147484e+9"
100string(12) "2.147484e+9 "
101string(12) "	2.147484e+9"
102string(12) "
1032.147484e+9"
104string(11) "2.147484e+9"
105string(30) "                   2.147484e+9"
106
107-- Iteration 6 --
108string(12) "-2.147484e+9"
109string(12) "-2.147484e+9"
110string(13) " -2.147484e+9"
111string(13) "-2.147484e+9 "
112string(13) "	-2.147484e+9"
113string(13) "
114-2.147484e+9"
115string(12) "-2.147484e+9"
116string(30) "                  -2.147484e+9"
117
118-- Iteration 7 --
119string(11) "0.000000e+0"
120string(11) "0.000000e+0"
121string(12) " 0.000000e+0"
122string(12) "0.000000e+0 "
123string(12) "	0.000000e+0"
124string(12) "
1250.000000e+0"
126string(11) "0.000000e+0"
127string(30) "                   0.000000e+0"
128
129-- Iteration 8 --
130string(12) "-1.000000e-1"
131string(12) "-1.000000e-1"
132string(13) " -1.000000e-1"
133string(13) "-1.000000e-1 "
134string(13) "	-1.000000e-1"
135string(13) "
136-1.000000e-1"
137string(12) "-1.000000e-1"
138string(30) "                  -1.000000e-1"
139
140-- Iteration 9 --
141string(11) "1.000000e+0"
142string(11) "1.000000e+0"
143string(12) " 1.000000e+0"
144string(12) "1.000000e+0 "
145string(12) "	1.000000e+0"
146string(12) "
1471.000000e+0"
148string(11) "1.000000e+0"
149string(30) "                   1.000000e+0"
150
151-- Iteration 10 --
152string(11) "1.000000e+5"
153string(11) "1.000000e+5"
154string(12) " 1.000000e+5"
155string(12) "1.000000e+5 "
156string(12) "	1.000000e+5"
157string(12) "
1581.000000e+5"
159string(11) "1.000000e+5"
160string(30) "                   1.000000e+5"
161
162-- Iteration 11 --
163string(12) "-1.000000e+5"
164string(12) "-1.000000e+5"
165string(13) " -1.000000e+5"
166string(13) "-1.000000e+5 "
167string(13) "	-1.000000e+5"
168string(13) "
169-1.000000e+5"
170string(12) "-1.000000e+5"
171string(30) "                  -1.000000e+5"
172
173-- Iteration 12 --
174string(12) "-1.000000e+5"
175string(12) "-1.000000e+5"
176string(13) " -1.000000e+5"
177string(13) "-1.000000e+5 "
178string(13) "	-1.000000e+5"
179string(13) "
180-1.000000e+5"
181string(12) "-1.000000e+5"
182string(30) "                  -1.000000e+5"
183
184-- Iteration 13 --
185string(11) "1.000000e+5"
186string(11) "1.000000e+5"
187string(12) " 1.000000e+5"
188string(12) "1.000000e+5 "
189string(12) "	1.000000e+5"
190string(12) "
1911.000000e+5"
192string(11) "1.000000e+5"
193string(30) "                   1.000000e+5"
194
195-- Iteration 14 --
196string(11) "1.000000e+5"
197string(11) "1.000000e+5"
198string(12) " 1.000000e+5"
199string(12) "1.000000e+5 "
200string(12) "	1.000000e+5"
201string(12) "
2021.000000e+5"
203string(11) "1.000000e+5"
204string(30) "                   1.000000e+5"
205
206-- Iteration 15 --
207string(12) "-1.000000e-5"
208string(12) "-1.000000e-5"
209string(13) " -1.000000e-5"
210string(13) "-1.000000e-5 "
211string(13) "	-1.000000e-5"
212string(13) "
213-1.000000e-5"
214string(12) "-1.000000e-5"
215string(30) "                  -1.000000e-5"
216
217-- Iteration 16 --
218string(11) "1.000000e+8"
219string(11) "1.000000e+8"
220string(12) " 1.000000e+8"
221string(12) "1.000000e+8 "
222string(12) "	1.000000e+8"
223string(12) "
2241.000000e+8"
225string(11) "1.000000e+8"
226string(30) "                   1.000000e+8"
227
228-- Iteration 17 --
229string(12) "-1.000000e+9"
230string(12) "-1.000000e+9"
231string(13) " -1.000000e+9"
232string(13) "-1.000000e+9 "
233string(13) "	-1.000000e+9"
234string(13) "
235-1.000000e+9"
236string(12) "-1.000000e+9"
237string(30) "                  -1.000000e+9"
238
239-- Iteration 18 --
240string(11) "1.000000e+1"
241string(11) "1.000000e+1"
242string(12) " 1.000000e+1"
243string(12) "1.000000e+1 "
244string(12) "	1.000000e+1"
245string(12) "
2461.000000e+1"
247string(11) "1.000000e+1"
248string(30) "                   1.000000e+1"
249
250-- Iteration 19 --
251string(11) "1.050000e+6"
252string(11) "1.050000e+6"
253string(12) " 1.050000e+6"
254string(12) "1.050000e+6 "
255string(12) "	1.050000e+6"
256string(12) "
2571.050000e+6"
258string(11) "1.050000e+6"
259string(30) "                   1.050000e+6"
260Done
261