1--TEST-- 2BcMath\Number div string by operator 3--EXTENSIONS-- 4bcmath 5--FILE-- 6<?php 7 8$values = [ 9 100, 10 '-20', 11 '0.01', 12 '-0.40', 13 3, 14]; 15 16foreach ($values as $value1) { 17 $num1 = new BcMath\Number($value1); 18 19 foreach ($values as $value2) { 20 echo "{$value1} / {$value2}\n"; 21 $ret = $num1 / ((string) $value2); 22 $ret2 = ((string) $value1) / (new BcMath\Number($value2)); 23 if ($ret->compare($ret2) !== 0) { 24 echo "Result is incorrect.\n"; 25 } 26 var_dump($ret); 27 echo "\n"; 28 } 29} 30?> 31--EXPECT-- 32100 / 100 33object(BcMath\Number)#2 (2) { 34 ["value"]=> 35 string(1) "1" 36 ["scale"]=> 37 int(0) 38} 39 40100 / -20 41object(BcMath\Number)#3 (2) { 42 ["value"]=> 43 string(2) "-5" 44 ["scale"]=> 45 int(0) 46} 47 48100 / 0.01 49object(BcMath\Number)#4 (2) { 50 ["value"]=> 51 string(5) "10000" 52 ["scale"]=> 53 int(0) 54} 55 56100 / -0.40 57object(BcMath\Number)#5 (2) { 58 ["value"]=> 59 string(4) "-250" 60 ["scale"]=> 61 int(0) 62} 63 64100 / 3 65object(BcMath\Number)#2 (2) { 66 ["value"]=> 67 string(13) "33.3333333333" 68 ["scale"]=> 69 int(10) 70} 71 72-20 / 100 73object(BcMath\Number)#1 (2) { 74 ["value"]=> 75 string(4) "-0.2" 76 ["scale"]=> 77 int(1) 78} 79 80-20 / -20 81object(BcMath\Number)#4 (2) { 82 ["value"]=> 83 string(1) "1" 84 ["scale"]=> 85 int(0) 86} 87 88-20 / 0.01 89object(BcMath\Number)#5 (2) { 90 ["value"]=> 91 string(5) "-2000" 92 ["scale"]=> 93 int(0) 94} 95 96-20 / -0.40 97object(BcMath\Number)#2 (2) { 98 ["value"]=> 99 string(2) "50" 100 ["scale"]=> 101 int(0) 102} 103 104-20 / 3 105object(BcMath\Number)#1 (2) { 106 ["value"]=> 107 string(13) "-6.6666666666" 108 ["scale"]=> 109 int(10) 110} 111 1120.01 / 100 113object(BcMath\Number)#3 (2) { 114 ["value"]=> 115 string(6) "0.0001" 116 ["scale"]=> 117 int(4) 118} 119 1200.01 / -20 121object(BcMath\Number)#5 (2) { 122 ["value"]=> 123 string(7) "-0.0005" 124 ["scale"]=> 125 int(4) 126} 127 1280.01 / 0.01 129object(BcMath\Number)#2 (2) { 130 ["value"]=> 131 string(4) "1.00" 132 ["scale"]=> 133 int(2) 134} 135 1360.01 / -0.40 137object(BcMath\Number)#1 (2) { 138 ["value"]=> 139 string(6) "-0.025" 140 ["scale"]=> 141 int(3) 142} 143 1440.01 / 3 145object(BcMath\Number)#3 (2) { 146 ["value"]=> 147 string(14) "0.003333333333" 148 ["scale"]=> 149 int(12) 150} 151 152-0.40 / 100 153object(BcMath\Number)#4 (2) { 154 ["value"]=> 155 string(6) "-0.004" 156 ["scale"]=> 157 int(3) 158} 159 160-0.40 / -20 161object(BcMath\Number)#2 (2) { 162 ["value"]=> 163 string(4) "0.02" 164 ["scale"]=> 165 int(2) 166} 167 168-0.40 / 0.01 169object(BcMath\Number)#1 (2) { 170 ["value"]=> 171 string(6) "-40.00" 172 ["scale"]=> 173 int(2) 174} 175 176-0.40 / -0.40 177object(BcMath\Number)#3 (2) { 178 ["value"]=> 179 string(4) "1.00" 180 ["scale"]=> 181 int(2) 182} 183 184-0.40 / 3 185object(BcMath\Number)#4 (2) { 186 ["value"]=> 187 string(15) "-0.133333333333" 188 ["scale"]=> 189 int(12) 190} 191 1923 / 100 193object(BcMath\Number)#5 (2) { 194 ["value"]=> 195 string(4) "0.03" 196 ["scale"]=> 197 int(2) 198} 199 2003 / -20 201object(BcMath\Number)#1 (2) { 202 ["value"]=> 203 string(5) "-0.15" 204 ["scale"]=> 205 int(2) 206} 207 2083 / 0.01 209object(BcMath\Number)#3 (2) { 210 ["value"]=> 211 string(3) "300" 212 ["scale"]=> 213 int(0) 214} 215 2163 / -0.40 217object(BcMath\Number)#4 (2) { 218 ["value"]=> 219 string(4) "-7.5" 220 ["scale"]=> 221 int(1) 222} 223 2243 / 3 225object(BcMath\Number)#5 (2) { 226 ["value"]=> 227 string(1) "1" 228 ["scale"]=> 229 int(0) 230} 231