1--TEST--
2BcMath\Number mod string by operator
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$values = [
9    100,
10    '-20',
11    9,
12];
13
14foreach ($values as $value1) {
15    $num1 = new BcMath\Number($value1);
16
17    foreach ($values as $value2) {
18        echo "{$value1} % {$value2}\n";
19        $ret = $num1 % ((string) $value2);
20        $ret2 = ((string) $value1) % (new BcMath\Number($value2));
21        if ($ret->compare($ret2) !== 0) {
22            echo "Result is incorrect.\n";
23        }
24        var_dump($ret);
25        echo "\n";
26    }
27}
28?>
29--EXPECT--
30100 % 100
31object(BcMath\Number)#2 (2) {
32  ["value"]=>
33  string(1) "0"
34  ["scale"]=>
35  int(0)
36}
37
38100 % -20
39object(BcMath\Number)#3 (2) {
40  ["value"]=>
41  string(1) "0"
42  ["scale"]=>
43  int(0)
44}
45
46100 % 9
47object(BcMath\Number)#4 (2) {
48  ["value"]=>
49  string(1) "1"
50  ["scale"]=>
51  int(0)
52}
53
54-20 % 100
55object(BcMath\Number)#1 (2) {
56  ["value"]=>
57  string(3) "-20"
58  ["scale"]=>
59  int(0)
60}
61
62-20 % -20
63object(BcMath\Number)#2 (2) {
64  ["value"]=>
65  string(1) "0"
66  ["scale"]=>
67  int(0)
68}
69
70-20 % 9
71object(BcMath\Number)#3 (2) {
72  ["value"]=>
73  string(2) "-2"
74  ["scale"]=>
75  int(0)
76}
77
789 % 100
79object(BcMath\Number)#5 (2) {
80  ["value"]=>
81  string(1) "9"
82  ["scale"]=>
83  int(0)
84}
85
869 % -20
87object(BcMath\Number)#1 (2) {
88  ["value"]=>
89  string(1) "9"
90  ["scale"]=>
91  int(0)
92}
93
949 % 9
95object(BcMath\Number)#2 (2) {
96  ["value"]=>
97  string(1) "0"
98  ["scale"]=>
99  int(0)
100}
101