1--TEST--
2pack()/unpack(): float/double tests
3--FILE--
4<?php
5var_dump(
6    'pack e',
7    bin2hex(pack("e", "")),
8    bin2hex(pack("e", "a")),
9    bin2hex(pack("e", " ")),
10    bin2hex(pack("e", NULL)),
11    bin2hex(pack("e", 0)),
12    bin2hex(pack("e", 1)),
13    bin2hex(pack("e", 1.0)),
14    bin2hex(pack("e", 10000000000000000)),
15    bin2hex(pack("e", 0.591234709823149)),
16    bin2hex(pack("e", 12345678901234567890.1234567898765432123456789)),
17    bin2hex(pack("e", -1)),
18    bin2hex(pack("e", -1.0)),
19    bin2hex(pack("e", -10000000000000000)),
20    bin2hex(pack("e", -0.591234709823149)),
21    bin2hex(pack("e", -12345678901234567890.1234567898765432123456789)),
22
23    'pack E',
24    bin2hex(pack("E", "")),
25    bin2hex(pack("E", "a")),
26    bin2hex(pack("E", " ")),
27    bin2hex(pack("E", NULL)),
28    bin2hex(pack("E", 0)),
29    bin2hex(pack("E", 1)),
30    bin2hex(pack("E", 1.0)),
31    bin2hex(pack("E", 10000000000000000)),
32    bin2hex(pack("E", 0.591234709823149)),
33    bin2hex(pack("E", 12345678901234567890.1234567898765432123456789)),
34    bin2hex(pack("E", -1)),
35    bin2hex(pack("E", -1.0)),
36    bin2hex(pack("E", -10000000000000000)),
37    bin2hex(pack("E", -0.591234709823149)),
38    bin2hex(pack("E", -12345678901234567890.1234567898765432123456789)),
39
40    'pack g',
41    bin2hex(pack("g", "")),
42    bin2hex(pack("g", "a")),
43    bin2hex(pack("g", " ")),
44    bin2hex(pack("g", NULL)),
45    bin2hex(pack("g", 0)),
46    bin2hex(pack("g", 1)),
47    bin2hex(pack("g", 1.0)),
48    bin2hex(pack("g", 10000000000000000)),
49    bin2hex(pack("g", 0.591234709823149)),
50    bin2hex(pack("g", 12345678901234567890.1234567898765432123456789)),
51    bin2hex(pack("g", -1)),
52    bin2hex(pack("g", -1.0)),
53    bin2hex(pack("g", -10000000000000000)),
54    bin2hex(pack("g", -0.591234709823149)),
55    bin2hex(pack("g", -12345678901234567890.1234567898765432123456789)),
56
57    'pack G',
58    bin2hex(pack("G", "")),
59    bin2hex(pack("G", "a")),
60    bin2hex(pack("G", " ")),
61    bin2hex(pack("G", NULL)),
62    bin2hex(pack("G", 0)),
63    bin2hex(pack("G", 1)),
64    bin2hex(pack("G", 1.0)),
65    bin2hex(pack("G", 10000000000000000)),
66    bin2hex(pack("G", 0.591234709823149)),
67    bin2hex(pack("G", 12345678901234567890.1234567898765432123456789)),
68    bin2hex(pack("G", -1)),
69    bin2hex(pack("G", -1.0)),
70    bin2hex(pack("G", -10000000000000000)),
71    bin2hex(pack("G", -0.591234709823149)),
72    bin2hex(pack("G", -12345678901234567890.1234567898765432123456789)),
73
74    'unpack e',
75    unpack('e', hex2bin('0000000000000000')),
76    unpack('e', hex2bin('000000000000f03f')),
77    unpack('e', hex2bin('0080e03779c34143')),
78    unpack('e', hex2bin('4a6ade0d65ebe23f')),
79    unpack('e', hex2bin('000000000000f0bf')),
80    unpack('e', hex2bin('0080e03779c341c3')),
81    unpack('e', hex2bin('4a6ade0d65ebe2bf')),
82    unpack('e', hex2bin('e1639d31956ae5c3')),
83
84    'unpack E',
85    unpack('E', hex2bin('3ff0000000000000')),
86    unpack('E', hex2bin('4341c37937e08000')),
87    unpack('E', hex2bin('3fe2eb650dde6a4a')),
88    unpack('E', hex2bin('43e56a95319d63e1')),
89    unpack('E', hex2bin('bff0000000000000')),
90    unpack('E', hex2bin('c341c37937e08000')),
91    unpack('E', hex2bin('bfe2eb650dde6a4a')),
92    unpack('E', hex2bin('c3e56a95319d63e1')),
93
94    'unpack g',
95    unpack('g', hex2bin('0000803f')),
96    unpack('g', hex2bin('ca1b0e5a')),
97    unpack('g', hex2bin('285b173f')),
98    unpack('g', hex2bin('aa542b5f')),
99    unpack('g', hex2bin('000080bf')),
100    unpack('g', hex2bin('ca1b0eda')),
101    unpack('g', hex2bin('285b17bf')),
102    unpack('g', hex2bin('aa542bdf')),
103
104    'unpack G',
105    unpack('G', hex2bin('3f800000')),
106    unpack('G', hex2bin('5a0e1bca')),
107    unpack('G', hex2bin('3f175b28')),
108    unpack('G', hex2bin('5f2b54aa')),
109    unpack('G', hex2bin('bf800000')),
110    unpack('G', hex2bin('da0e1bca')),
111    unpack('G', hex2bin('bf175b28')),
112    unpack('G', hex2bin('df2b54aa'))
113
114);
115?>
116--EXPECT--
117string(6) "pack e"
118string(16) "0000000000000000"
119string(16) "0000000000000000"
120string(16) "0000000000000000"
121string(16) "0000000000000000"
122string(16) "0000000000000000"
123string(16) "000000000000f03f"
124string(16) "000000000000f03f"
125string(16) "0080e03779c34143"
126string(16) "4a6ade0d65ebe23f"
127string(16) "e1639d31956ae543"
128string(16) "000000000000f0bf"
129string(16) "000000000000f0bf"
130string(16) "0080e03779c341c3"
131string(16) "4a6ade0d65ebe2bf"
132string(16) "e1639d31956ae5c3"
133string(6) "pack E"
134string(16) "0000000000000000"
135string(16) "0000000000000000"
136string(16) "0000000000000000"
137string(16) "0000000000000000"
138string(16) "0000000000000000"
139string(16) "3ff0000000000000"
140string(16) "3ff0000000000000"
141string(16) "4341c37937e08000"
142string(16) "3fe2eb650dde6a4a"
143string(16) "43e56a95319d63e1"
144string(16) "bff0000000000000"
145string(16) "bff0000000000000"
146string(16) "c341c37937e08000"
147string(16) "bfe2eb650dde6a4a"
148string(16) "c3e56a95319d63e1"
149string(6) "pack g"
150string(8) "00000000"
151string(8) "00000000"
152string(8) "00000000"
153string(8) "00000000"
154string(8) "00000000"
155string(8) "0000803f"
156string(8) "0000803f"
157string(8) "ca1b0e5a"
158string(8) "285b173f"
159string(8) "aa542b5f"
160string(8) "000080bf"
161string(8) "000080bf"
162string(8) "ca1b0eda"
163string(8) "285b17bf"
164string(8) "aa542bdf"
165string(6) "pack G"
166string(8) "00000000"
167string(8) "00000000"
168string(8) "00000000"
169string(8) "00000000"
170string(8) "00000000"
171string(8) "3f800000"
172string(8) "3f800000"
173string(8) "5a0e1bca"
174string(8) "3f175b28"
175string(8) "5f2b54aa"
176string(8) "bf800000"
177string(8) "bf800000"
178string(8) "da0e1bca"
179string(8) "bf175b28"
180string(8) "df2b54aa"
181string(8) "unpack e"
182array(1) {
183  [1]=>
184  float(0)
185}
186array(1) {
187  [1]=>
188  float(1)
189}
190array(1) {
191  [1]=>
192  float(1.0E+16)
193}
194array(1) {
195  [1]=>
196  float(0.59123470982315)
197}
198array(1) {
199  [1]=>
200  float(-1)
201}
202array(1) {
203  [1]=>
204  float(-1.0E+16)
205}
206array(1) {
207  [1]=>
208  float(-0.59123470982315)
209}
210array(1) {
211  [1]=>
212  float(-1.2345678901235E+19)
213}
214string(8) "unpack E"
215array(1) {
216  [1]=>
217  float(1)
218}
219array(1) {
220  [1]=>
221  float(1.0E+16)
222}
223array(1) {
224  [1]=>
225  float(0.59123470982315)
226}
227array(1) {
228  [1]=>
229  float(1.2345678901235E+19)
230}
231array(1) {
232  [1]=>
233  float(-1)
234}
235array(1) {
236  [1]=>
237  float(-1.0E+16)
238}
239array(1) {
240  [1]=>
241  float(-0.59123470982315)
242}
243array(1) {
244  [1]=>
245  float(-1.2345678901235E+19)
246}
247string(8) "unpack g"
248array(1) {
249  [1]=>
250  float(1)
251}
252array(1) {
253  [1]=>
254  float(1.0000000272564E+16)
255}
256array(1) {
257  [1]=>
258  float(0.59123468399048)
259}
260array(1) {
261  [1]=>
262  float(1.2345679395506E+19)
263}
264array(1) {
265  [1]=>
266  float(-1)
267}
268array(1) {
269  [1]=>
270  float(-1.0000000272564E+16)
271}
272array(1) {
273  [1]=>
274  float(-0.59123468399048)
275}
276array(1) {
277  [1]=>
278  float(-1.2345679395506E+19)
279}
280string(8) "unpack G"
281array(1) {
282  [1]=>
283  float(1)
284}
285array(1) {
286  [1]=>
287  float(1.0000000272564E+16)
288}
289array(1) {
290  [1]=>
291  float(0.59123468399048)
292}
293array(1) {
294  [1]=>
295  float(1.2345679395506E+19)
296}
297array(1) {
298  [1]=>
299  float(-1)
300}
301array(1) {
302  [1]=>
303  float(-1.0000000272564E+16)
304}
305array(1) {
306  [1]=>
307  float(-0.59123468399048)
308}
309array(1) {
310  [1]=>
311  float(-1.2345679395506E+19)
312}
313