1--TEST-- 2BcMath\Number pow object by operator 3--EXTENSIONS-- 4bcmath 5--FILE-- 6<?php 7 8$values = [ 9 100, 10 '-20', 11 '0.01', 12 '-0.40', 13 3, 14]; 15 16$exponents = [ 17 2, 18 '3', 19 0, 20 -1, 21 -2, 22]; 23 24foreach ($values as $value) { 25 $num1 = new BcMath\Number($value); 26 27 foreach ($exponents as $exponent) { 28 echo "{$value} ** {$exponent}\n"; 29 $num2 = new BcMath\Number($exponent); 30 $ret = $num1 ** $num2; 31 var_dump($ret); 32 echo "\n"; 33 } 34} 35?> 36--EXPECT-- 37100 ** 2 38object(BcMath\Number)#3 (2) { 39 ["value"]=> 40 string(5) "10000" 41 ["scale"]=> 42 int(0) 43} 44 45100 ** 3 46object(BcMath\Number)#2 (2) { 47 ["value"]=> 48 string(7) "1000000" 49 ["scale"]=> 50 int(0) 51} 52 53100 ** 0 54object(BcMath\Number)#4 (2) { 55 ["value"]=> 56 string(1) "1" 57 ["scale"]=> 58 int(0) 59} 60 61100 ** -1 62object(BcMath\Number)#3 (2) { 63 ["value"]=> 64 string(4) "0.01" 65 ["scale"]=> 66 int(2) 67} 68 69100 ** -2 70object(BcMath\Number)#2 (2) { 71 ["value"]=> 72 string(6) "0.0001" 73 ["scale"]=> 74 int(4) 75} 76 77-20 ** 2 78object(BcMath\Number)#4 (2) { 79 ["value"]=> 80 string(3) "400" 81 ["scale"]=> 82 int(0) 83} 84 85-20 ** 3 86object(BcMath\Number)#1 (2) { 87 ["value"]=> 88 string(5) "-8000" 89 ["scale"]=> 90 int(0) 91} 92 93-20 ** 0 94object(BcMath\Number)#2 (2) { 95 ["value"]=> 96 string(1) "1" 97 ["scale"]=> 98 int(0) 99} 100 101-20 ** -1 102object(BcMath\Number)#4 (2) { 103 ["value"]=> 104 string(5) "-0.05" 105 ["scale"]=> 106 int(2) 107} 108 109-20 ** -2 110object(BcMath\Number)#1 (2) { 111 ["value"]=> 112 string(6) "0.0025" 113 ["scale"]=> 114 int(4) 115} 116 1170.01 ** 2 118object(BcMath\Number)#2 (2) { 119 ["value"]=> 120 string(6) "0.0001" 121 ["scale"]=> 122 int(4) 123} 124 1250.01 ** 3 126object(BcMath\Number)#3 (2) { 127 ["value"]=> 128 string(8) "0.000001" 129 ["scale"]=> 130 int(6) 131} 132 1330.01 ** 0 134object(BcMath\Number)#1 (2) { 135 ["value"]=> 136 string(1) "1" 137 ["scale"]=> 138 int(0) 139} 140 1410.01 ** -1 142object(BcMath\Number)#2 (2) { 143 ["value"]=> 144 string(6) "100.00" 145 ["scale"]=> 146 int(2) 147} 148 1490.01 ** -2 150object(BcMath\Number)#3 (2) { 151 ["value"]=> 152 string(8) "10000.00" 153 ["scale"]=> 154 int(2) 155} 156 157-0.40 ** 2 158object(BcMath\Number)#1 (2) { 159 ["value"]=> 160 string(6) "0.1600" 161 ["scale"]=> 162 int(4) 163} 164 165-0.40 ** 3 166object(BcMath\Number)#4 (2) { 167 ["value"]=> 168 string(9) "-0.064000" 169 ["scale"]=> 170 int(6) 171} 172 173-0.40 ** 0 174object(BcMath\Number)#3 (2) { 175 ["value"]=> 176 string(1) "1" 177 ["scale"]=> 178 int(0) 179} 180 181-0.40 ** -1 182object(BcMath\Number)#1 (2) { 183 ["value"]=> 184 string(5) "-2.50" 185 ["scale"]=> 186 int(2) 187} 188 189-0.40 ** -2 190object(BcMath\Number)#4 (2) { 191 ["value"]=> 192 string(4) "6.25" 193 ["scale"]=> 194 int(2) 195} 196 1973 ** 2 198object(BcMath\Number)#3 (2) { 199 ["value"]=> 200 string(1) "9" 201 ["scale"]=> 202 int(0) 203} 204 2053 ** 3 206object(BcMath\Number)#2 (2) { 207 ["value"]=> 208 string(2) "27" 209 ["scale"]=> 210 int(0) 211} 212 2133 ** 0 214object(BcMath\Number)#4 (2) { 215 ["value"]=> 216 string(1) "1" 217 ["scale"]=> 218 int(0) 219} 220 2213 ** -1 222object(BcMath\Number)#3 (2) { 223 ["value"]=> 224 string(12) "0.3333333333" 225 ["scale"]=> 226 int(10) 227} 228 2293 ** -2 230object(BcMath\Number)#2 (2) { 231 ["value"]=> 232 string(12) "0.1111111111" 233 ["scale"]=> 234 int(10) 235} 236