1--TEST-- 2BcMath\Number sub() 3--EXTENSIONS-- 4bcmath 5--FILE-- 6<?php 7 8$values1 = ['100.012', '-100.012']; 9 10$values2 = [ 11 [100, 'int'], 12 [-30, 'int'], 13 ['-20', 'string'], 14 ['0.01', 'string'], 15 ['-0.40', 'string'], 16 [new BcMath\Number('80.3'), 'object'], 17 [new BcMath\Number('-50.6'), 'object'], 18]; 19 20foreach ($values1 as $value1) { 21 $num = new BcMath\Number($value1); 22 23 foreach ($values2 as [$value2, $type]) { 24 echo "{$value1} - {$value2}: {$type}\n"; 25 $ret = $num->sub($value2); 26 var_dump($ret); 27 echo "\n"; 28 } 29} 30?> 31--EXPECT-- 32100.012 - 100: int 33object(BcMath\Number)#4 (2) { 34 ["value"]=> 35 string(5) "0.012" 36 ["scale"]=> 37 int(3) 38} 39 40100.012 - -30: int 41object(BcMath\Number)#5 (2) { 42 ["value"]=> 43 string(7) "130.012" 44 ["scale"]=> 45 int(3) 46} 47 48100.012 - -20: string 49object(BcMath\Number)#4 (2) { 50 ["value"]=> 51 string(7) "120.012" 52 ["scale"]=> 53 int(3) 54} 55 56100.012 - 0.01: string 57object(BcMath\Number)#5 (2) { 58 ["value"]=> 59 string(7) "100.002" 60 ["scale"]=> 61 int(3) 62} 63 64100.012 - -0.40: string 65object(BcMath\Number)#4 (2) { 66 ["value"]=> 67 string(7) "100.412" 68 ["scale"]=> 69 int(3) 70} 71 72100.012 - 80.3: object 73object(BcMath\Number)#5 (2) { 74 ["value"]=> 75 string(6) "19.712" 76 ["scale"]=> 77 int(3) 78} 79 80100.012 - -50.6: object 81object(BcMath\Number)#4 (2) { 82 ["value"]=> 83 string(7) "150.612" 84 ["scale"]=> 85 int(3) 86} 87 88-100.012 - 100: int 89object(BcMath\Number)#3 (2) { 90 ["value"]=> 91 string(8) "-200.012" 92 ["scale"]=> 93 int(3) 94} 95 96-100.012 - -30: int 97object(BcMath\Number)#4 (2) { 98 ["value"]=> 99 string(7) "-70.012" 100 ["scale"]=> 101 int(3) 102} 103 104-100.012 - -20: string 105object(BcMath\Number)#3 (2) { 106 ["value"]=> 107 string(7) "-80.012" 108 ["scale"]=> 109 int(3) 110} 111 112-100.012 - 0.01: string 113object(BcMath\Number)#4 (2) { 114 ["value"]=> 115 string(8) "-100.022" 116 ["scale"]=> 117 int(3) 118} 119 120-100.012 - -0.40: string 121object(BcMath\Number)#3 (2) { 122 ["value"]=> 123 string(7) "-99.612" 124 ["scale"]=> 125 int(3) 126} 127 128-100.012 - 80.3: object 129object(BcMath\Number)#4 (2) { 130 ["value"]=> 131 string(8) "-180.312" 132 ["scale"]=> 133 int(3) 134} 135 136-100.012 - -50.6: object 137object(BcMath\Number)#3 (2) { 138 ["value"]=> 139 string(7) "-49.412" 140 ["scale"]=> 141 int(3) 142} 143