xref: /php-src/ext/bcmath/tests/bcsub.phpt (revision ee226128)
1--TEST--
2bcsub() function
3--EXTENSIONS--
4bcmath
5--INI--
6bcmath.scale=0
7--FILE--
8<?php
9require(__DIR__ . "/run_bcmath_tests_function.inc");
10
11$minuends = ["15", "-15", "1", "-9", "14.14", "-16.60", "0.15", "-0.01"];
12$subtrahends = array_merge($minuends, [
13    "0",
14    "0.00",
15    "-0",
16    "-0.00",
17    "15151324141414.412312232141241",
18    "-132132245132134.1515123765412",
19    "141241241241241248267654747412",
20    "-149143276547656984948124912",
21    "0.1322135476547459213732911312",
22    "-0.123912932193769965476541321",
23]);
24
25run_bcmath_tests($minuends, $subtrahends, "-", bcsub(...));
26
27?>
28--EXPECT--
29Number "15" (scale 0)
3015 - 15                             = 0
3115 - -15                            = 30
3215 - 1                              = 14
3315 - -9                             = 24
3415 - 14.14                          = 0
3515 - -16.60                         = 31
3615 - 0.15                           = 14
3715 - -0.01                          = 15
3815 - 0                              = 15
3915 - 0.00                           = 15
4015 - -0                             = 15
4115 - -0.00                          = 15
4215 - 15151324141414.412312232141241 = -15151324141399
4315 - -132132245132134.1515123765412 = 132132245132149
4415 - 141241241241241248267654747412 = -141241241241241248267654747397
4515 - -149143276547656984948124912   = 149143276547656984948124927
4615 - 0.1322135476547459213732911312 = 14
4715 - -0.123912932193769965476541321 = 15
48
49Number "-15" (scale 0)
50-15 - 15                             = -30
51-15 - -15                            = 0
52-15 - 1                              = -16
53-15 - -9                             = -6
54-15 - 14.14                          = -29
55-15 - -16.60                         = 1
56-15 - 0.15                           = -15
57-15 - -0.01                          = -14
58-15 - 0                              = -15
59-15 - 0.00                           = -15
60-15 - -0                             = -15
61-15 - -0.00                          = -15
62-15 - 15151324141414.412312232141241 = -15151324141429
63-15 - -132132245132134.1515123765412 = 132132245132119
64-15 - 141241241241241248267654747412 = -141241241241241248267654747427
65-15 - -149143276547656984948124912   = 149143276547656984948124897
66-15 - 0.1322135476547459213732911312 = -15
67-15 - -0.123912932193769965476541321 = -14
68
69Number "1" (scale 0)
701 - 15                             = -14
711 - -15                            = 16
721 - 1                              = 0
731 - -9                             = 10
741 - 14.14                          = -13
751 - -16.60                         = 17
761 - 0.15                           = 0
771 - -0.01                          = 1
781 - 0                              = 1
791 - 0.00                           = 1
801 - -0                             = 1
811 - -0.00                          = 1
821 - 15151324141414.412312232141241 = -15151324141413
831 - -132132245132134.1515123765412 = 132132245132135
841 - 141241241241241248267654747412 = -141241241241241248267654747411
851 - -149143276547656984948124912   = 149143276547656984948124913
861 - 0.1322135476547459213732911312 = 0
871 - -0.123912932193769965476541321 = 1
88
89Number "-9" (scale 0)
90-9 - 15                             = -24
91-9 - -15                            = 6
92-9 - 1                              = -10
93-9 - -9                             = 0
94-9 - 14.14                          = -23
95-9 - -16.60                         = 7
96-9 - 0.15                           = -9
97-9 - -0.01                          = -8
98-9 - 0                              = -9
99-9 - 0.00                           = -9
100-9 - -0                             = -9
101-9 - -0.00                          = -9
102-9 - 15151324141414.412312232141241 = -15151324141423
103-9 - -132132245132134.1515123765412 = 132132245132125
104-9 - 141241241241241248267654747412 = -141241241241241248267654747421
105-9 - -149143276547656984948124912   = 149143276547656984948124903
106-9 - 0.1322135476547459213732911312 = -9
107-9 - -0.123912932193769965476541321 = -8
108
109Number "14.14" (scale 0)
11014.14 - 15                             = 0
11114.14 - -15                            = 29
11214.14 - 1                              = 13
11314.14 - -9                             = 23
11414.14 - 14.14                          = 0
11514.14 - -16.60                         = 30
11614.14 - 0.15                           = 13
11714.14 - -0.01                          = 14
11814.14 - 0                              = 14
11914.14 - 0.00                           = 14
12014.14 - -0                             = 14
12114.14 - -0.00                          = 14
12214.14 - 15151324141414.412312232141241 = -15151324141400
12314.14 - -132132245132134.1515123765412 = 132132245132148
12414.14 - 141241241241241248267654747412 = -141241241241241248267654747397
12514.14 - -149143276547656984948124912   = 149143276547656984948124926
12614.14 - 0.1322135476547459213732911312 = 14
12714.14 - -0.123912932193769965476541321 = 14
128
129Number "-16.60" (scale 0)
130-16.60 - 15                             = -31
131-16.60 - -15                            = -1
132-16.60 - 1                              = -17
133-16.60 - -9                             = -7
134-16.60 - 14.14                          = -30
135-16.60 - -16.60                         = 0
136-16.60 - 0.15                           = -16
137-16.60 - -0.01                          = -16
138-16.60 - 0                              = -16
139-16.60 - 0.00                           = -16
140-16.60 - -0                             = -16
141-16.60 - -0.00                          = -16
142-16.60 - 15151324141414.412312232141241 = -15151324141431
143-16.60 - -132132245132134.1515123765412 = 132132245132117
144-16.60 - 141241241241241248267654747412 = -141241241241241248267654747428
145-16.60 - -149143276547656984948124912   = 149143276547656984948124895
146-16.60 - 0.1322135476547459213732911312 = -16
147-16.60 - -0.123912932193769965476541321 = -16
148
149Number "0.15" (scale 0)
1500.15 - 15                             = -14
1510.15 - -15                            = 15
1520.15 - 1                              = 0
1530.15 - -9                             = 9
1540.15 - 14.14                          = -13
1550.15 - -16.60                         = 16
1560.15 - 0.15                           = 0
1570.15 - -0.01                          = 0
1580.15 - 0                              = 0
1590.15 - 0.00                           = 0
1600.15 - -0                             = 0
1610.15 - -0.00                          = 0
1620.15 - 15151324141414.412312232141241 = -15151324141414
1630.15 - -132132245132134.1515123765412 = 132132245132134
1640.15 - 141241241241241248267654747412 = -141241241241241248267654747411
1650.15 - -149143276547656984948124912   = 149143276547656984948124912
1660.15 - 0.1322135476547459213732911312 = 0
1670.15 - -0.123912932193769965476541321 = 0
168
169Number "-0.01" (scale 0)
170-0.01 - 15                             = -15
171-0.01 - -15                            = 14
172-0.01 - 1                              = -1
173-0.01 - -9                             = 8
174-0.01 - 14.14                          = -14
175-0.01 - -16.60                         = 16
176-0.01 - 0.15                           = 0
177-0.01 - -0.01                          = 0
178-0.01 - 0                              = 0
179-0.01 - 0.00                           = 0
180-0.01 - -0                             = 0
181-0.01 - -0.00                          = 0
182-0.01 - 15151324141414.412312232141241 = -15151324141414
183-0.01 - -132132245132134.1515123765412 = 132132245132134
184-0.01 - 141241241241241248267654747412 = -141241241241241248267654747412
185-0.01 - -149143276547656984948124912   = 149143276547656984948124911
186-0.01 - 0.1322135476547459213732911312 = 0
187-0.01 - -0.123912932193769965476541321 = 0
188
189Number "15" (scale 10)
19015 - 15                             = 0.0000000000
19115 - -15                            = 30.0000000000
19215 - 1                              = 14.0000000000
19315 - -9                             = 24.0000000000
19415 - 14.14                          = 0.8600000000
19515 - -16.60                         = 31.6000000000
19615 - 0.15                           = 14.8500000000
19715 - -0.01                          = 15.0100000000
19815 - 0                              = 15.0000000000
19915 - 0.00                           = 15.0000000000
20015 - -0                             = 15.0000000000
20115 - -0.00                          = 15.0000000000
20215 - 15151324141414.412312232141241 = -15151324141399.4123122321
20315 - -132132245132134.1515123765412 = 132132245132149.1515123765
20415 - 141241241241241248267654747412 = -141241241241241248267654747397.0000000000
20515 - -149143276547656984948124912   = 149143276547656984948124927.0000000000
20615 - 0.1322135476547459213732911312 = 14.8677864523
20715 - -0.123912932193769965476541321 = 15.1239129321
208
209Number "-15" (scale 10)
210-15 - 15                             = -30.0000000000
211-15 - -15                            = 0.0000000000
212-15 - 1                              = -16.0000000000
213-15 - -9                             = -6.0000000000
214-15 - 14.14                          = -29.1400000000
215-15 - -16.60                         = 1.6000000000
216-15 - 0.15                           = -15.1500000000
217-15 - -0.01                          = -14.9900000000
218-15 - 0                              = -15.0000000000
219-15 - 0.00                           = -15.0000000000
220-15 - -0                             = -15.0000000000
221-15 - -0.00                          = -15.0000000000
222-15 - 15151324141414.412312232141241 = -15151324141429.4123122321
223-15 - -132132245132134.1515123765412 = 132132245132119.1515123765
224-15 - 141241241241241248267654747412 = -141241241241241248267654747427.0000000000
225-15 - -149143276547656984948124912   = 149143276547656984948124897.0000000000
226-15 - 0.1322135476547459213732911312 = -15.1322135476
227-15 - -0.123912932193769965476541321 = -14.8760870678
228
229Number "1" (scale 10)
2301 - 15                             = -14.0000000000
2311 - -15                            = 16.0000000000
2321 - 1                              = 0.0000000000
2331 - -9                             = 10.0000000000
2341 - 14.14                          = -13.1400000000
2351 - -16.60                         = 17.6000000000
2361 - 0.15                           = 0.8500000000
2371 - -0.01                          = 1.0100000000
2381 - 0                              = 1.0000000000
2391 - 0.00                           = 1.0000000000
2401 - -0                             = 1.0000000000
2411 - -0.00                          = 1.0000000000
2421 - 15151324141414.412312232141241 = -15151324141413.4123122321
2431 - -132132245132134.1515123765412 = 132132245132135.1515123765
2441 - 141241241241241248267654747412 = -141241241241241248267654747411.0000000000
2451 - -149143276547656984948124912   = 149143276547656984948124913.0000000000
2461 - 0.1322135476547459213732911312 = 0.8677864523
2471 - -0.123912932193769965476541321 = 1.1239129321
248
249Number "-9" (scale 10)
250-9 - 15                             = -24.0000000000
251-9 - -15                            = 6.0000000000
252-9 - 1                              = -10.0000000000
253-9 - -9                             = 0.0000000000
254-9 - 14.14                          = -23.1400000000
255-9 - -16.60                         = 7.6000000000
256-9 - 0.15                           = -9.1500000000
257-9 - -0.01                          = -8.9900000000
258-9 - 0                              = -9.0000000000
259-9 - 0.00                           = -9.0000000000
260-9 - -0                             = -9.0000000000
261-9 - -0.00                          = -9.0000000000
262-9 - 15151324141414.412312232141241 = -15151324141423.4123122321
263-9 - -132132245132134.1515123765412 = 132132245132125.1515123765
264-9 - 141241241241241248267654747412 = -141241241241241248267654747421.0000000000
265-9 - -149143276547656984948124912   = 149143276547656984948124903.0000000000
266-9 - 0.1322135476547459213732911312 = -9.1322135476
267-9 - -0.123912932193769965476541321 = -8.8760870678
268
269Number "14.14" (scale 10)
27014.14 - 15                             = -0.8600000000
27114.14 - -15                            = 29.1400000000
27214.14 - 1                              = 13.1400000000
27314.14 - -9                             = 23.1400000000
27414.14 - 14.14                          = 0.0000000000
27514.14 - -16.60                         = 30.7400000000
27614.14 - 0.15                           = 13.9900000000
27714.14 - -0.01                          = 14.1500000000
27814.14 - 0                              = 14.1400000000
27914.14 - 0.00                           = 14.1400000000
28014.14 - -0                             = 14.1400000000
28114.14 - -0.00                          = 14.1400000000
28214.14 - 15151324141414.412312232141241 = -15151324141400.2723122321
28314.14 - -132132245132134.1515123765412 = 132132245132148.2915123765
28414.14 - 141241241241241248267654747412 = -141241241241241248267654747397.8600000000
28514.14 - -149143276547656984948124912   = 149143276547656984948124926.1400000000
28614.14 - 0.1322135476547459213732911312 = 14.0077864523
28714.14 - -0.123912932193769965476541321 = 14.2639129321
288
289Number "-16.60" (scale 10)
290-16.60 - 15                             = -31.6000000000
291-16.60 - -15                            = -1.6000000000
292-16.60 - 1                              = -17.6000000000
293-16.60 - -9                             = -7.6000000000
294-16.60 - 14.14                          = -30.7400000000
295-16.60 - -16.60                         = 0.0000000000
296-16.60 - 0.15                           = -16.7500000000
297-16.60 - -0.01                          = -16.5900000000
298-16.60 - 0                              = -16.6000000000
299-16.60 - 0.00                           = -16.6000000000
300-16.60 - -0                             = -16.6000000000
301-16.60 - -0.00                          = -16.6000000000
302-16.60 - 15151324141414.412312232141241 = -15151324141431.0123122321
303-16.60 - -132132245132134.1515123765412 = 132132245132117.5515123765
304-16.60 - 141241241241241248267654747412 = -141241241241241248267654747428.6000000000
305-16.60 - -149143276547656984948124912   = 149143276547656984948124895.4000000000
306-16.60 - 0.1322135476547459213732911312 = -16.7322135476
307-16.60 - -0.123912932193769965476541321 = -16.4760870678
308
309Number "0.15" (scale 10)
3100.15 - 15                             = -14.8500000000
3110.15 - -15                            = 15.1500000000
3120.15 - 1                              = -0.8500000000
3130.15 - -9                             = 9.1500000000
3140.15 - 14.14                          = -13.9900000000
3150.15 - -16.60                         = 16.7500000000
3160.15 - 0.15                           = 0.0000000000
3170.15 - -0.01                          = 0.1600000000
3180.15 - 0                              = 0.1500000000
3190.15 - 0.00                           = 0.1500000000
3200.15 - -0                             = 0.1500000000
3210.15 - -0.00                          = 0.1500000000
3220.15 - 15151324141414.412312232141241 = -15151324141414.2623122321
3230.15 - -132132245132134.1515123765412 = 132132245132134.3015123765
3240.15 - 141241241241241248267654747412 = -141241241241241248267654747411.8500000000
3250.15 - -149143276547656984948124912   = 149143276547656984948124912.1500000000
3260.15 - 0.1322135476547459213732911312 = 0.0177864523
3270.15 - -0.123912932193769965476541321 = 0.2739129321
328
329Number "-0.01" (scale 10)
330-0.01 - 15                             = -15.0100000000
331-0.01 - -15                            = 14.9900000000
332-0.01 - 1                              = -1.0100000000
333-0.01 - -9                             = 8.9900000000
334-0.01 - 14.14                          = -14.1500000000
335-0.01 - -16.60                         = 16.5900000000
336-0.01 - 0.15                           = -0.1600000000
337-0.01 - -0.01                          = 0.0000000000
338-0.01 - 0                              = -0.0100000000
339-0.01 - 0.00                           = -0.0100000000
340-0.01 - -0                             = -0.0100000000
341-0.01 - -0.00                          = -0.0100000000
342-0.01 - 15151324141414.412312232141241 = -15151324141414.4223122321
343-0.01 - -132132245132134.1515123765412 = 132132245132134.1415123765
344-0.01 - 141241241241241248267654747412 = -141241241241241248267654747412.0100000000
345-0.01 - -149143276547656984948124912   = 149143276547656984948124911.9900000000
346-0.01 - 0.1322135476547459213732911312 = -0.1422135476
347-0.01 - -0.123912932193769965476541321 = 0.1139129321
348