1--TEST-- 2fpow() function 3--FILE-- 4<?php 5 6$numbers = [ 7 0, 8 1, 9 -1, 10 1.0, 11 -1.0, 12 2, 13 -2, 14 2.1, 15 -2.1, 16 0.1, 17 -0.1, 18 0.0, 19 -0.0, 20 10, 21 -10, 22 INF, 23 -INF, 24 NAN, 25]; 26 27foreach ($numbers as $base) { 28 foreach ($numbers as $exp) { 29 print str_pad($base, 4, " ", STR_PAD_LEFT) . 30 " ** " . 31 str_pad($exp, 4) . 32 " = " . 33 fpow($base, $exp) . 34 PHP_EOL; 35 } 36} 37?> 38--EXPECT-- 39 0 ** 0 = 1 40 0 ** 1 = 0 41 0 ** -1 = INF 42 0 ** 1 = 0 43 0 ** -1 = INF 44 0 ** 2 = 0 45 0 ** -2 = INF 46 0 ** 2.1 = 0 47 0 ** -2.1 = INF 48 0 ** 0.1 = 0 49 0 ** -0.1 = INF 50 0 ** 0 = 1 51 0 ** -0 = 1 52 0 ** 10 = 0 53 0 ** -10 = INF 54 0 ** INF = 0 55 0 ** -INF = INF 56 0 ** NAN = NAN 57 1 ** 0 = 1 58 1 ** 1 = 1 59 1 ** -1 = 1 60 1 ** 1 = 1 61 1 ** -1 = 1 62 1 ** 2 = 1 63 1 ** -2 = 1 64 1 ** 2.1 = 1 65 1 ** -2.1 = 1 66 1 ** 0.1 = 1 67 1 ** -0.1 = 1 68 1 ** 0 = 1 69 1 ** -0 = 1 70 1 ** 10 = 1 71 1 ** -10 = 1 72 1 ** INF = 1 73 1 ** -INF = 1 74 1 ** NAN = 1 75 -1 ** 0 = 1 76 -1 ** 1 = -1 77 -1 ** -1 = -1 78 -1 ** 1 = -1 79 -1 ** -1 = -1 80 -1 ** 2 = 1 81 -1 ** -2 = 1 82 -1 ** 2.1 = NAN 83 -1 ** -2.1 = NAN 84 -1 ** 0.1 = NAN 85 -1 ** -0.1 = NAN 86 -1 ** 0 = 1 87 -1 ** -0 = 1 88 -1 ** 10 = 1 89 -1 ** -10 = 1 90 -1 ** INF = 1 91 -1 ** -INF = 1 92 -1 ** NAN = NAN 93 1 ** 0 = 1 94 1 ** 1 = 1 95 1 ** -1 = 1 96 1 ** 1 = 1 97 1 ** -1 = 1 98 1 ** 2 = 1 99 1 ** -2 = 1 100 1 ** 2.1 = 1 101 1 ** -2.1 = 1 102 1 ** 0.1 = 1 103 1 ** -0.1 = 1 104 1 ** 0 = 1 105 1 ** -0 = 1 106 1 ** 10 = 1 107 1 ** -10 = 1 108 1 ** INF = 1 109 1 ** -INF = 1 110 1 ** NAN = 1 111 -1 ** 0 = 1 112 -1 ** 1 = -1 113 -1 ** -1 = -1 114 -1 ** 1 = -1 115 -1 ** -1 = -1 116 -1 ** 2 = 1 117 -1 ** -2 = 1 118 -1 ** 2.1 = NAN 119 -1 ** -2.1 = NAN 120 -1 ** 0.1 = NAN 121 -1 ** -0.1 = NAN 122 -1 ** 0 = 1 123 -1 ** -0 = 1 124 -1 ** 10 = 1 125 -1 ** -10 = 1 126 -1 ** INF = 1 127 -1 ** -INF = 1 128 -1 ** NAN = NAN 129 2 ** 0 = 1 130 2 ** 1 = 2 131 2 ** -1 = 0.5 132 2 ** 1 = 2 133 2 ** -1 = 0.5 134 2 ** 2 = 4 135 2 ** -2 = 0.25 136 2 ** 2.1 = 4.2870938501452 137 2 ** -2.1 = 0.2332582478842 138 2 ** 0.1 = 1.0717734625363 139 2 ** -0.1 = 0.93303299153681 140 2 ** 0 = 1 141 2 ** -0 = 1 142 2 ** 10 = 1024 143 2 ** -10 = 0.0009765625 144 2 ** INF = INF 145 2 ** -INF = 0 146 2 ** NAN = NAN 147 -2 ** 0 = 1 148 -2 ** 1 = -2 149 -2 ** -1 = -0.5 150 -2 ** 1 = -2 151 -2 ** -1 = -0.5 152 -2 ** 2 = 4 153 -2 ** -2 = 0.25 154 -2 ** 2.1 = NAN 155 -2 ** -2.1 = NAN 156 -2 ** 0.1 = NAN 157 -2 ** -0.1 = NAN 158 -2 ** 0 = 1 159 -2 ** -0 = 1 160 -2 ** 10 = 1024 161 -2 ** -10 = 0.0009765625 162 -2 ** INF = INF 163 -2 ** -INF = 0 164 -2 ** NAN = NAN 165 2.1 ** 0 = 1 166 2.1 ** 1 = 2.1 167 2.1 ** -1 = 0.47619047619048 168 2.1 ** 1 = 2.1 169 2.1 ** -1 = 0.47619047619048 170 2.1 ** 2 = 4.41 171 2.1 ** -2 = 0.22675736961451 172 2.1 ** 2.1 = 4.7496380917422 173 2.1 ** -2.1 = 0.21054235726688 174 2.1 ** 0.1 = 1.0770154403044 175 2.1 ** -0.1 = 0.92849179554696 176 2.1 ** 0 = 1 177 2.1 ** -0 = 1 178 2.1 ** 10 = 1667.9880978201 179 2.1 ** -10 = 0.0005995246616609 180 2.1 ** INF = INF 181 2.1 ** -INF = 0 182 2.1 ** NAN = NAN 183-2.1 ** 0 = 1 184-2.1 ** 1 = -2.1 185-2.1 ** -1 = -0.47619047619048 186-2.1 ** 1 = -2.1 187-2.1 ** -1 = -0.47619047619048 188-2.1 ** 2 = 4.41 189-2.1 ** -2 = 0.22675736961451 190-2.1 ** 2.1 = NAN 191-2.1 ** -2.1 = NAN 192-2.1 ** 0.1 = NAN 193-2.1 ** -0.1 = NAN 194-2.1 ** 0 = 1 195-2.1 ** -0 = 1 196-2.1 ** 10 = 1667.9880978201 197-2.1 ** -10 = 0.0005995246616609 198-2.1 ** INF = INF 199-2.1 ** -INF = 0 200-2.1 ** NAN = NAN 201 0.1 ** 0 = 1 202 0.1 ** 1 = 0.1 203 0.1 ** -1 = 10 204 0.1 ** 1 = 0.1 205 0.1 ** -1 = 10 206 0.1 ** 2 = 0.01 207 0.1 ** -2 = 100 208 0.1 ** 2.1 = 0.0079432823472428 209 0.1 ** -2.1 = 125.89254117942 210 0.1 ** 0.1 = 0.79432823472428 211 0.1 ** -0.1 = 1.2589254117942 212 0.1 ** 0 = 1 213 0.1 ** -0 = 1 214 0.1 ** 10 = 1.0E-10 215 0.1 ** -10 = 10000000000 216 0.1 ** INF = 0 217 0.1 ** -INF = INF 218 0.1 ** NAN = NAN 219-0.1 ** 0 = 1 220-0.1 ** 1 = -0.1 221-0.1 ** -1 = -10 222-0.1 ** 1 = -0.1 223-0.1 ** -1 = -10 224-0.1 ** 2 = 0.01 225-0.1 ** -2 = 100 226-0.1 ** 2.1 = NAN 227-0.1 ** -2.1 = NAN 228-0.1 ** 0.1 = NAN 229-0.1 ** -0.1 = NAN 230-0.1 ** 0 = 1 231-0.1 ** -0 = 1 232-0.1 ** 10 = 1.0E-10 233-0.1 ** -10 = 10000000000 234-0.1 ** INF = 0 235-0.1 ** -INF = INF 236-0.1 ** NAN = NAN 237 0 ** 0 = 1 238 0 ** 1 = 0 239 0 ** -1 = INF 240 0 ** 1 = 0 241 0 ** -1 = INF 242 0 ** 2 = 0 243 0 ** -2 = INF 244 0 ** 2.1 = 0 245 0 ** -2.1 = INF 246 0 ** 0.1 = 0 247 0 ** -0.1 = INF 248 0 ** 0 = 1 249 0 ** -0 = 1 250 0 ** 10 = 0 251 0 ** -10 = INF 252 0 ** INF = 0 253 0 ** -INF = INF 254 0 ** NAN = NAN 255 -0 ** 0 = 1 256 -0 ** 1 = -0 257 -0 ** -1 = -INF 258 -0 ** 1 = -0 259 -0 ** -1 = -INF 260 -0 ** 2 = 0 261 -0 ** -2 = INF 262 -0 ** 2.1 = 0 263 -0 ** -2.1 = INF 264 -0 ** 0.1 = 0 265 -0 ** -0.1 = INF 266 -0 ** 0 = 1 267 -0 ** -0 = 1 268 -0 ** 10 = 0 269 -0 ** -10 = INF 270 -0 ** INF = 0 271 -0 ** -INF = INF 272 -0 ** NAN = NAN 273 10 ** 0 = 1 274 10 ** 1 = 10 275 10 ** -1 = 0.1 276 10 ** 1 = 10 277 10 ** -1 = 0.1 278 10 ** 2 = 100 279 10 ** -2 = 0.01 280 10 ** 2.1 = 125.89254117942 281 10 ** -2.1 = 0.0079432823472428 282 10 ** 0.1 = 1.2589254117942 283 10 ** -0.1 = 0.79432823472428 284 10 ** 0 = 1 285 10 ** -0 = 1 286 10 ** 10 = 10000000000 287 10 ** -10 = 1.0E-10 288 10 ** INF = INF 289 10 ** -INF = 0 290 10 ** NAN = NAN 291 -10 ** 0 = 1 292 -10 ** 1 = -10 293 -10 ** -1 = -0.1 294 -10 ** 1 = -10 295 -10 ** -1 = -0.1 296 -10 ** 2 = 100 297 -10 ** -2 = 0.01 298 -10 ** 2.1 = NAN 299 -10 ** -2.1 = NAN 300 -10 ** 0.1 = NAN 301 -10 ** -0.1 = NAN 302 -10 ** 0 = 1 303 -10 ** -0 = 1 304 -10 ** 10 = 10000000000 305 -10 ** -10 = 1.0E-10 306 -10 ** INF = INF 307 -10 ** -INF = 0 308 -10 ** NAN = NAN 309 INF ** 0 = 1 310 INF ** 1 = INF 311 INF ** -1 = 0 312 INF ** 1 = INF 313 INF ** -1 = 0 314 INF ** 2 = INF 315 INF ** -2 = 0 316 INF ** 2.1 = INF 317 INF ** -2.1 = 0 318 INF ** 0.1 = INF 319 INF ** -0.1 = 0 320 INF ** 0 = 1 321 INF ** -0 = 1 322 INF ** 10 = INF 323 INF ** -10 = 0 324 INF ** INF = INF 325 INF ** -INF = 0 326 INF ** NAN = NAN 327-INF ** 0 = 1 328-INF ** 1 = -INF 329-INF ** -1 = -0 330-INF ** 1 = -INF 331-INF ** -1 = -0 332-INF ** 2 = INF 333-INF ** -2 = 0 334-INF ** 2.1 = INF 335-INF ** -2.1 = 0 336-INF ** 0.1 = INF 337-INF ** -0.1 = 0 338-INF ** 0 = 1 339-INF ** -0 = 1 340-INF ** 10 = INF 341-INF ** -10 = 0 342-INF ** INF = INF 343-INF ** -INF = 0 344-INF ** NAN = NAN 345 NAN ** 0 = 1 346 NAN ** 1 = NAN 347 NAN ** -1 = NAN 348 NAN ** 1 = NAN 349 NAN ** -1 = NAN 350 NAN ** 2 = NAN 351 NAN ** -2 = NAN 352 NAN ** 2.1 = NAN 353 NAN ** -2.1 = NAN 354 NAN ** 0.1 = NAN 355 NAN ** -0.1 = NAN 356 NAN ** 0 = 1 357 NAN ** -0 = 1 358 NAN ** 10 = NAN 359 NAN ** -10 = NAN 360 NAN ** INF = NAN 361 NAN ** -INF = NAN 362 NAN ** NAN = NAN 363