1--TEST--
2BcMath\Number pow int by operator
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$values = [
9    100,
10    '-20',
11    3,
12];
13
14$exponents = [
15    2,
16    '3',
17    0,
18    -1,
19    -2,
20];
21
22foreach ($values as $value) {
23    $num1 = new BcMath\Number($value);
24
25    foreach ($exponents as $exponent) {
26        echo "{$value} ** {$exponent}\n";
27        $ret = $num1 ** ((int) $exponent);
28        $ret2 = ((int) $value) ** (new BcMath\Number($exponent));
29        if ($ret->compare($ret2) !== 0) {
30            echo "Result is incorrect.\n";
31        }
32        var_dump($ret);
33        echo "\n";
34    }
35}
36?>
37--EXPECT--
38100 ** 2
39object(BcMath\Number)#2 (2) {
40  ["value"]=>
41  string(5) "10000"
42  ["scale"]=>
43  int(0)
44}
45
46100 ** 3
47object(BcMath\Number)#3 (2) {
48  ["value"]=>
49  string(7) "1000000"
50  ["scale"]=>
51  int(0)
52}
53
54100 ** 0
55object(BcMath\Number)#4 (2) {
56  ["value"]=>
57  string(1) "1"
58  ["scale"]=>
59  int(0)
60}
61
62100 ** -1
63object(BcMath\Number)#5 (2) {
64  ["value"]=>
65  string(4) "0.01"
66  ["scale"]=>
67  int(2)
68}
69
70100 ** -2
71object(BcMath\Number)#2 (2) {
72  ["value"]=>
73  string(6) "0.0001"
74  ["scale"]=>
75  int(4)
76}
77
78-20 ** 2
79object(BcMath\Number)#1 (2) {
80  ["value"]=>
81  string(3) "400"
82  ["scale"]=>
83  int(0)
84}
85
86-20 ** 3
87object(BcMath\Number)#4 (2) {
88  ["value"]=>
89  string(5) "-8000"
90  ["scale"]=>
91  int(0)
92}
93
94-20 ** 0
95object(BcMath\Number)#5 (2) {
96  ["value"]=>
97  string(1) "1"
98  ["scale"]=>
99  int(0)
100}
101
102-20 ** -1
103object(BcMath\Number)#2 (2) {
104  ["value"]=>
105  string(5) "-0.05"
106  ["scale"]=>
107  int(2)
108}
109
110-20 ** -2
111object(BcMath\Number)#1 (2) {
112  ["value"]=>
113  string(6) "0.0025"
114  ["scale"]=>
115  int(4)
116}
117
1183 ** 2
119object(BcMath\Number)#3 (2) {
120  ["value"]=>
121  string(1) "9"
122  ["scale"]=>
123  int(0)
124}
125
1263 ** 3
127object(BcMath\Number)#5 (2) {
128  ["value"]=>
129  string(2) "27"
130  ["scale"]=>
131  int(0)
132}
133
1343 ** 0
135object(BcMath\Number)#2 (2) {
136  ["value"]=>
137  string(1) "1"
138  ["scale"]=>
139  int(0)
140}
141
1423 ** -1
143object(BcMath\Number)#1 (2) {
144  ["value"]=>
145  string(12) "0.3333333333"
146  ["scale"]=>
147  int(10)
148}
149
1503 ** -2
151object(BcMath\Number)#3 (2) {
152  ["value"]=>
153  string(12) "0.1111111111"
154  ["scale"]=>
155  int(10)
156}
157