1--TEST--
2BcMath\Number compare() with scale
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$values2 = [
9    [100, 'int'],
10    ['100.0000', 'string'],
11    [new BcMath\Number('100.0000'), 'object'],
12    ['100.0001', 'string'],
13    [new BcMath\Number('100.0001'), 'object'],
14    ['100.0010', 'string'],
15    [new BcMath\Number('100.0010'), 'object'],
16    ['100.0100', 'string'],
17    [new BcMath\Number('100.0100'), 'object'],
18    ['100.0011', 'string'],
19    [new BcMath\Number('100.0011'), 'object'],
20];
21
22$value1 = new BcMath\Number('100.0011');
23
24$scales = [0, 1, 2, 3, 4, 5];
25
26foreach ($scales as $scale) {
27    echo "========== scale is {$scale} ==========\n";
28    foreach ($values2 as [$value2, $type2]) {
29        echo "with {$type2} {$value2}:\n";
30        var_dump($value1->compare($value2, $scale));
31
32        echo "\n";
33    }
34}
35?>
36--EXPECT--
37========== scale is 0 ==========
38with int 100:
39int(0)
40
41with string 100.0000:
42int(0)
43
44with object 100.0000:
45int(0)
46
47with string 100.0001:
48int(0)
49
50with object 100.0001:
51int(0)
52
53with string 100.0010:
54int(0)
55
56with object 100.0010:
57int(0)
58
59with string 100.0100:
60int(0)
61
62with object 100.0100:
63int(0)
64
65with string 100.0011:
66int(0)
67
68with object 100.0011:
69int(0)
70
71========== scale is 1 ==========
72with int 100:
73int(0)
74
75with string 100.0000:
76int(0)
77
78with object 100.0000:
79int(0)
80
81with string 100.0001:
82int(0)
83
84with object 100.0001:
85int(0)
86
87with string 100.0010:
88int(0)
89
90with object 100.0010:
91int(0)
92
93with string 100.0100:
94int(0)
95
96with object 100.0100:
97int(0)
98
99with string 100.0011:
100int(0)
101
102with object 100.0011:
103int(0)
104
105========== scale is 2 ==========
106with int 100:
107int(0)
108
109with string 100.0000:
110int(0)
111
112with object 100.0000:
113int(0)
114
115with string 100.0001:
116int(0)
117
118with object 100.0001:
119int(0)
120
121with string 100.0010:
122int(0)
123
124with object 100.0010:
125int(0)
126
127with string 100.0100:
128int(-1)
129
130with object 100.0100:
131int(-1)
132
133with string 100.0011:
134int(0)
135
136with object 100.0011:
137int(0)
138
139========== scale is 3 ==========
140with int 100:
141int(1)
142
143with string 100.0000:
144int(1)
145
146with object 100.0000:
147int(1)
148
149with string 100.0001:
150int(1)
151
152with object 100.0001:
153int(1)
154
155with string 100.0010:
156int(0)
157
158with object 100.0010:
159int(0)
160
161with string 100.0100:
162int(-1)
163
164with object 100.0100:
165int(-1)
166
167with string 100.0011:
168int(0)
169
170with object 100.0011:
171int(0)
172
173========== scale is 4 ==========
174with int 100:
175int(1)
176
177with string 100.0000:
178int(1)
179
180with object 100.0000:
181int(1)
182
183with string 100.0001:
184int(1)
185
186with object 100.0001:
187int(1)
188
189with string 100.0010:
190int(1)
191
192with object 100.0010:
193int(1)
194
195with string 100.0100:
196int(-1)
197
198with object 100.0100:
199int(-1)
200
201with string 100.0011:
202int(0)
203
204with object 100.0011:
205int(0)
206
207========== scale is 5 ==========
208with int 100:
209int(1)
210
211with string 100.0000:
212int(1)
213
214with object 100.0000:
215int(1)
216
217with string 100.0001:
218int(1)
219
220with object 100.0001:
221int(1)
222
223with string 100.0010:
224int(1)
225
226with object 100.0010:
227int(1)
228
229with string 100.0100:
230int(-1)
231
232with object 100.0100:
233int(-1)
234
235with string 100.0011:
236int(0)
237
238with object 100.0011:
239int(0)
240