1--TEST-- 2BcMath\Number pow() with scale 3--EXTENSIONS-- 4bcmath 5--FILE-- 6<?php 7 8$scales = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 9 10$values = ['12.5', '-12.5']; 11 12$exponents = [ 13 [2, 'int'], 14 [-3, 'int'], 15 ['-2', 'string'], 16 ['0', 'string'], 17 [new BcMath\Number('2'), 'object'], 18 [new BcMath\Number('-2'), 'object'], 19 [new BcMath\Number('0'), 'object'], 20]; 21 22foreach ($scales as $scale) { 23 foreach ($values as $value) { 24 $num = new BcMath\Number($value); 25 26 foreach ($exponents as [$exponent, $type]) { 27 $func_ret = bcpow($value, (string) $exponent, $scale); 28 $method_ret = $num->pow($exponent, $scale); 29 if ($method_ret->compare($func_ret) !== 0) { 30 echo "Result is incorrect.\n"; 31 var_dump($value, $exponent, $scale, $func_ret, $method_ret); 32 } 33 } 34 } 35} 36echo 'done!'; 37?> 38--EXPECT-- 39done! 40