1--TEST-- 2BcMath\Number divmod() 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_quot, $func_rem] = bcdivmod($value1, (string) $value2, $scale); 28 [$method_quot, $method_rem] = $num->divmod($value2, $scale); 29 if ($method_quot->compare($func_quot) !== 0) { 30 echo "Quot is incorrect.\n"; 31 var_dump($value1, $value2, $scale, $func_quot, $method_quot); 32 } 33 if ($method_rem->compare($func_rem) !== 0) { 34 echo "Rem is incorrect.\n"; 35 var_dump($value1, $value2, $scale, $func_rem, $method_rem); 36 } 37 } 38 } 39} 40echo 'done!'; 41?> 42--EXPECT-- 43done! 44