1--TEST-- 2BcMath\Number div() 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$values1 = ['100.012', '-100.012']; 11 12$values2 = [ 13 [100, 'int'], 14 [-30, 'int'], 15 ['-20', 'string'], 16 ['0.01', 'string'], 17 ['-0.40', 'string'], 18 [new BcMath\Number('80.3'), 'object'], 19 [new BcMath\Number('-50.6'), 'object'], 20]; 21 22foreach ($scales as $scale) { 23 foreach ($values1 as $value1) { 24 $num = new BcMath\Number($value1); 25 26 foreach ($values2 as [$value2, $type]) { 27 $func_ret = bcdiv($value1, (string) $value2, $scale); 28 $method_ret = $num->div($value2, $scale); 29 if ($method_ret->compare($func_ret) !== 0) { 30 echo "Result is incorrect.\n"; 31 var_dump($value1, $value2, $scale, $func_ret, $method_ret); 32 } 33 } 34 } 35} 36echo 'done!'; 37?> 38--EXPECT-- 39done! 40