xref: /PHP-5.6/ext/standard/tests/math/pow_basic.phpt (revision c731b228)
1--TEST--
2Test pow() - basic function test pow()
3--INI--
4precision=14
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
8?>
9--FILE--
10<?php
11$bases = array(23,
12				-23,
13				23.1,
14				-23.1,
15				2.345e1,
16				-2.345e1,
17				0x17,
18				027,
19				"23",
20				"23.45",
21				"2.345e1",
22				PHP_INT_MAX,
23				-PHP_INT_MAX - 1);
24
25$exponents = array(0,
26               1,
27               -1,
28               2,
29               -2,
30               3,
31               -3,
32               2.5,
33               -2.5,
34               500,
35               -500,
36               2147483647,
37			   -2147483648);
38
39foreach($bases as $base) {
40	echo "\n\nBase = $base";
41	foreach($exponents as $exponent) {
42		echo "\n..... Exponent = $exponent Result = ";
43		$res = pow($base, $exponent);
44		echo $res;
45	}
46	echo "\n\n";
47}
48?>
49===Done===
50--EXPECT--
51Base = 23
52..... Exponent = 0 Result = 1
53..... Exponent = 1 Result = 23
54..... Exponent = -1 Result = 0.043478260869565
55..... Exponent = 2 Result = 529
56..... Exponent = -2 Result = 0.001890359168242
57..... Exponent = 3 Result = 12167
58..... Exponent = -3 Result = 8.2189529053999E-5
59..... Exponent = 2.5 Result = 2536.9948758324
60..... Exponent = -2.5 Result = 0.00039416713432339
61..... Exponent = 500 Result = INF
62..... Exponent = -500 Result = 0
63..... Exponent = 2147483647 Result = INF
64..... Exponent = -2147483648 Result = 0
65
66
67
68Base = -23
69..... Exponent = 0 Result = 1
70..... Exponent = 1 Result = -23
71..... Exponent = -1 Result = -0.043478260869565
72..... Exponent = 2 Result = 529
73..... Exponent = -2 Result = 0.001890359168242
74..... Exponent = 3 Result = -12167
75..... Exponent = -3 Result = -8.2189529053999E-5
76..... Exponent = 2.5 Result = NAN
77..... Exponent = -2.5 Result = NAN
78..... Exponent = 500 Result = INF
79..... Exponent = -500 Result = 0
80..... Exponent = 2147483647 Result = -INF
81..... Exponent = -2147483648 Result = 0
82
83
84
85Base = 23.1
86..... Exponent = 0 Result = 1
87..... Exponent = 1 Result = 23.1
88..... Exponent = -1 Result = 0.043290043290043
89..... Exponent = 2 Result = 533.61
90..... Exponent = -2 Result = 0.0018740278480538
91..... Exponent = 3 Result = 12326.391
92..... Exponent = -3 Result = 8.1126746668997E-5
93..... Exponent = 2.5 Result = 2564.6608940579
94..... Exponent = -2.5 Result = 0.00038991509650141
95..... Exponent = 500 Result = INF
96..... Exponent = -500 Result = 0
97..... Exponent = 2147483647 Result = INF
98..... Exponent = -2147483648 Result = 0
99
100
101
102Base = -23.1
103..... Exponent = 0 Result = 1
104..... Exponent = 1 Result = -23.1
105..... Exponent = -1 Result = -0.043290043290043
106..... Exponent = 2 Result = 533.61
107..... Exponent = -2 Result = 0.0018740278480538
108..... Exponent = 3 Result = -12326.391
109..... Exponent = -3 Result = -8.1126746668997E-5
110..... Exponent = 2.5 Result = NAN
111..... Exponent = -2.5 Result = NAN
112..... Exponent = 500 Result = INF
113..... Exponent = -500 Result = 0
114..... Exponent = 2147483647 Result = -INF
115..... Exponent = -2147483648 Result = 0
116
117
118
119Base = 23.45
120..... Exponent = 0 Result = 1
121..... Exponent = 1 Result = 23.45
122..... Exponent = -1 Result = 0.042643923240938
123..... Exponent = 2 Result = 549.9025
124..... Exponent = -2 Result = 0.001818504189379
125..... Exponent = 3 Result = 12895.213625
126..... Exponent = -3 Result = 7.7548153065204E-5
127..... Exponent = 2.5 Result = 2662.9138571162
128..... Exponent = -2.5 Result = 0.00037552848257846
129..... Exponent = 500 Result = INF
130..... Exponent = -500 Result = 0
131..... Exponent = 2147483647 Result = INF
132..... Exponent = -2147483648 Result = 0
133
134
135
136Base = -23.45
137..... Exponent = 0 Result = 1
138..... Exponent = 1 Result = -23.45
139..... Exponent = -1 Result = -0.042643923240938
140..... Exponent = 2 Result = 549.9025
141..... Exponent = -2 Result = 0.001818504189379
142..... Exponent = 3 Result = -12895.213625
143..... Exponent = -3 Result = -7.7548153065204E-5
144..... Exponent = 2.5 Result = NAN
145..... Exponent = -2.5 Result = NAN
146..... Exponent = 500 Result = INF
147..... Exponent = -500 Result = 0
148..... Exponent = 2147483647 Result = -INF
149..... Exponent = -2147483648 Result = 0
150
151
152
153Base = 23
154..... Exponent = 0 Result = 1
155..... Exponent = 1 Result = 23
156..... Exponent = -1 Result = 0.043478260869565
157..... Exponent = 2 Result = 529
158..... Exponent = -2 Result = 0.001890359168242
159..... Exponent = 3 Result = 12167
160..... Exponent = -3 Result = 8.2189529053999E-5
161..... Exponent = 2.5 Result = 2536.9948758324
162..... Exponent = -2.5 Result = 0.00039416713432339
163..... Exponent = 500 Result = INF
164..... Exponent = -500 Result = 0
165..... Exponent = 2147483647 Result = INF
166..... Exponent = -2147483648 Result = 0
167
168
169
170Base = 23
171..... Exponent = 0 Result = 1
172..... Exponent = 1 Result = 23
173..... Exponent = -1 Result = 0.043478260869565
174..... Exponent = 2 Result = 529
175..... Exponent = -2 Result = 0.001890359168242
176..... Exponent = 3 Result = 12167
177..... Exponent = -3 Result = 8.2189529053999E-5
178..... Exponent = 2.5 Result = 2536.9948758324
179..... Exponent = -2.5 Result = 0.00039416713432339
180..... Exponent = 500 Result = INF
181..... Exponent = -500 Result = 0
182..... Exponent = 2147483647 Result = INF
183..... Exponent = -2147483648 Result = 0
184
185
186
187Base = 23
188..... Exponent = 0 Result = 1
189..... Exponent = 1 Result = 23
190..... Exponent = -1 Result = 0.043478260869565
191..... Exponent = 2 Result = 529
192..... Exponent = -2 Result = 0.001890359168242
193..... Exponent = 3 Result = 12167
194..... Exponent = -3 Result = 8.2189529053999E-5
195..... Exponent = 2.5 Result = 2536.9948758324
196..... Exponent = -2.5 Result = 0.00039416713432339
197..... Exponent = 500 Result = INF
198..... Exponent = -500 Result = 0
199..... Exponent = 2147483647 Result = INF
200..... Exponent = -2147483648 Result = 0
201
202
203
204Base = 23.45
205..... Exponent = 0 Result = 1
206..... Exponent = 1 Result = 23.45
207..... Exponent = -1 Result = 0.042643923240938
208..... Exponent = 2 Result = 549.9025
209..... Exponent = -2 Result = 0.001818504189379
210..... Exponent = 3 Result = 12895.213625
211..... Exponent = -3 Result = 7.7548153065204E-5
212..... Exponent = 2.5 Result = 2662.9138571162
213..... Exponent = -2.5 Result = 0.00037552848257846
214..... Exponent = 500 Result = INF
215..... Exponent = -500 Result = 0
216..... Exponent = 2147483647 Result = INF
217..... Exponent = -2147483648 Result = 0
218
219
220
221Base = 2.345e1
222..... Exponent = 0 Result = 1
223..... Exponent = 1 Result = 23.45
224..... Exponent = -1 Result = 0.042643923240938
225..... Exponent = 2 Result = 549.9025
226..... Exponent = -2 Result = 0.001818504189379
227..... Exponent = 3 Result = 12895.213625
228..... Exponent = -3 Result = 7.7548153065204E-5
229..... Exponent = 2.5 Result = 2662.9138571162
230..... Exponent = -2.5 Result = 0.00037552848257846
231..... Exponent = 500 Result = INF
232..... Exponent = -500 Result = 0
233..... Exponent = 2147483647 Result = INF
234..... Exponent = -2147483648 Result = 0
235
236
237
238Base = 2147483647
239..... Exponent = 0 Result = 1
240..... Exponent = 1 Result = 2147483647
241..... Exponent = -1 Result = 4.6566128752458E-10
242..... Exponent = 2 Result = 4.6116860141324E+18
243..... Exponent = -2 Result = 2.1684043469905E-19
244..... Exponent = 3 Result = 9.903520300448E+27
245..... Exponent = -3 Result = 1.0097419600935E-28
246..... Exponent = 2.5 Result = 2.1370991100146E+23
247..... Exponent = -2.5 Result = 4.6792401686657E-24
248..... Exponent = 500 Result = INF
249..... Exponent = -500 Result = 0
250..... Exponent = 2147483647 Result = INF
251..... Exponent = -2147483648 Result = 0
252
253
254
255Base = -2147483648
256..... Exponent = 0 Result = 1
257..... Exponent = 1 Result = -2147483648
258..... Exponent = -1 Result = -4.6566128730774E-10
259..... Exponent = 2 Result = 4.6116860184274E+18
260..... Exponent = -2 Result = 2.168404344971E-19
261..... Exponent = 3 Result = -9.903520314283E+27
262..... Exponent = -3 Result = -1.0097419586829E-28
263..... Exponent = 2.5 Result = NAN
264..... Exponent = -2.5 Result = NAN
265..... Exponent = 500 Result = INF
266..... Exponent = -500 Result = 0
267..... Exponent = 2147483647 Result = -INF
268..... Exponent = -2147483648 Result = 0
269
270===Done===