1--TEST--
2BcMath\Number divmod()
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} divmod {$value2}: {$type}\n";
25        [$quot, $rem] = $num->divmod($value2);
26        var_dump($quot, $rem);
27        echo "\n";
28    }
29}
30?>
31--EXPECT--
32100.012 divmod 100: int
33object(BcMath\Number)#4 (2) {
34  ["value"]=>
35  string(1) "1"
36  ["scale"]=>
37  int(0)
38}
39object(BcMath\Number)#5 (2) {
40  ["value"]=>
41  string(5) "0.012"
42  ["scale"]=>
43  int(3)
44}
45
46100.012 divmod -30: int
47object(BcMath\Number)#6 (2) {
48  ["value"]=>
49  string(2) "-3"
50  ["scale"]=>
51  int(0)
52}
53object(BcMath\Number)#7 (2) {
54  ["value"]=>
55  string(6) "10.012"
56  ["scale"]=>
57  int(3)
58}
59
60100.012 divmod -20: string
61object(BcMath\Number)#5 (2) {
62  ["value"]=>
63  string(2) "-5"
64  ["scale"]=>
65  int(0)
66}
67object(BcMath\Number)#4 (2) {
68  ["value"]=>
69  string(5) "0.012"
70  ["scale"]=>
71  int(3)
72}
73
74100.012 divmod 0.01: string
75object(BcMath\Number)#7 (2) {
76  ["value"]=>
77  string(5) "10001"
78  ["scale"]=>
79  int(0)
80}
81object(BcMath\Number)#6 (2) {
82  ["value"]=>
83  string(5) "0.002"
84  ["scale"]=>
85  int(3)
86}
87
88100.012 divmod -0.40: string
89object(BcMath\Number)#4 (2) {
90  ["value"]=>
91  string(4) "-250"
92  ["scale"]=>
93  int(0)
94}
95object(BcMath\Number)#5 (2) {
96  ["value"]=>
97  string(5) "0.012"
98  ["scale"]=>
99  int(3)
100}
101
102100.012 divmod 80.3: object
103object(BcMath\Number)#6 (2) {
104  ["value"]=>
105  string(1) "1"
106  ["scale"]=>
107  int(0)
108}
109object(BcMath\Number)#7 (2) {
110  ["value"]=>
111  string(6) "19.712"
112  ["scale"]=>
113  int(3)
114}
115
116100.012 divmod -50.6: object
117object(BcMath\Number)#5 (2) {
118  ["value"]=>
119  string(2) "-1"
120  ["scale"]=>
121  int(0)
122}
123object(BcMath\Number)#4 (2) {
124  ["value"]=>
125  string(6) "49.412"
126  ["scale"]=>
127  int(3)
128}
129
130-100.012 divmod 100: int
131object(BcMath\Number)#3 (2) {
132  ["value"]=>
133  string(2) "-1"
134  ["scale"]=>
135  int(0)
136}
137object(BcMath\Number)#6 (2) {
138  ["value"]=>
139  string(6) "-0.012"
140  ["scale"]=>
141  int(3)
142}
143
144-100.012 divmod -30: int
145object(BcMath\Number)#4 (2) {
146  ["value"]=>
147  string(1) "3"
148  ["scale"]=>
149  int(0)
150}
151object(BcMath\Number)#5 (2) {
152  ["value"]=>
153  string(7) "-10.012"
154  ["scale"]=>
155  int(3)
156}
157
158-100.012 divmod -20: string
159object(BcMath\Number)#6 (2) {
160  ["value"]=>
161  string(1) "5"
162  ["scale"]=>
163  int(0)
164}
165object(BcMath\Number)#3 (2) {
166  ["value"]=>
167  string(6) "-0.012"
168  ["scale"]=>
169  int(3)
170}
171
172-100.012 divmod 0.01: string
173object(BcMath\Number)#5 (2) {
174  ["value"]=>
175  string(6) "-10001"
176  ["scale"]=>
177  int(0)
178}
179object(BcMath\Number)#4 (2) {
180  ["value"]=>
181  string(6) "-0.002"
182  ["scale"]=>
183  int(3)
184}
185
186-100.012 divmod -0.40: string
187object(BcMath\Number)#3 (2) {
188  ["value"]=>
189  string(3) "250"
190  ["scale"]=>
191  int(0)
192}
193object(BcMath\Number)#6 (2) {
194  ["value"]=>
195  string(6) "-0.012"
196  ["scale"]=>
197  int(3)
198}
199
200-100.012 divmod 80.3: object
201object(BcMath\Number)#4 (2) {
202  ["value"]=>
203  string(2) "-1"
204  ["scale"]=>
205  int(0)
206}
207object(BcMath\Number)#5 (2) {
208  ["value"]=>
209  string(7) "-19.712"
210  ["scale"]=>
211  int(3)
212}
213
214-100.012 divmod -50.6: object
215object(BcMath\Number)#6 (2) {
216  ["value"]=>
217  string(1) "1"
218  ["scale"]=>
219  int(0)
220}
221object(BcMath\Number)#3 (2) {
222  ["value"]=>
223  string(7) "-49.412"
224  ["scale"]=>
225  int(3)
226}
227