xref: /php-src/ext/bcmath/tests/bcmul.phpt (revision ee226128)
1--TEST--
2bcmul() function
3--EXTENSIONS--
4bcmath
5--INI--
6bcmath.scale=0
7--FILE--
8<?php
9require(__DIR__ . "/run_bcmath_tests_function.inc");
10
11$firstFactors = ["15", "-15", "1", "-9", "14.14", "-16.60", "0.15", "-0.01"];
12$secondFactors = array_merge($firstFactors, [
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($firstFactors, $secondFactors, "*", bcmul(...));
26
27?>
28--EXPECT--
29Number "15" (scale 0)
3015 * 15                             = 225
3115 * -15                            = -225
3215 * 1                              = 15
3315 * -9                             = -135
3415 * 14.14                          = 212
3515 * -16.60                         = -249
3615 * 0.15                           = 2
3715 * -0.01                          = 0
3815 * 0                              = 0
3915 * 0.00                           = 0
4015 * -0                             = 0
4115 * -0.00                          = 0
4215 * 15151324141414.412312232141241 = 227269862121216
4315 * -132132245132134.1515123765412 = -1981983676982012
4415 * 141241241241241248267654747412 = 2118618618618618724014821211180
4515 * -149143276547656984948124912   = -2237149148214854774221873680
4615 * 0.1322135476547459213732911312 = 1
4715 * -0.123912932193769965476541321 = -1
48
49Number "-15" (scale 0)
50-15 * 15                             = -225
51-15 * -15                            = 225
52-15 * 1                              = -15
53-15 * -9                             = 135
54-15 * 14.14                          = -212
55-15 * -16.60                         = 249
56-15 * 0.15                           = -2
57-15 * -0.01                          = 0
58-15 * 0                              = 0
59-15 * 0.00                           = 0
60-15 * -0                             = 0
61-15 * -0.00                          = 0
62-15 * 15151324141414.412312232141241 = -227269862121216
63-15 * -132132245132134.1515123765412 = 1981983676982012
64-15 * 141241241241241248267654747412 = -2118618618618618724014821211180
65-15 * -149143276547656984948124912   = 2237149148214854774221873680
66-15 * 0.1322135476547459213732911312 = -1
67-15 * -0.123912932193769965476541321 = 1
68
69Number "1" (scale 0)
701 * 15                             = 15
711 * -15                            = -15
721 * 1                              = 1
731 * -9                             = -9
741 * 14.14                          = 14
751 * -16.60                         = -16
761 * 0.15                           = 0
771 * -0.01                          = 0
781 * 0                              = 0
791 * 0.00                           = 0
801 * -0                             = 0
811 * -0.00                          = 0
821 * 15151324141414.412312232141241 = 15151324141414
831 * -132132245132134.1515123765412 = -132132245132134
841 * 141241241241241248267654747412 = 141241241241241248267654747412
851 * -149143276547656984948124912   = -149143276547656984948124912
861 * 0.1322135476547459213732911312 = 0
871 * -0.123912932193769965476541321 = 0
88
89Number "-9" (scale 0)
90-9 * 15                             = -135
91-9 * -15                            = 135
92-9 * 1                              = -9
93-9 * -9                             = 81
94-9 * 14.14                          = -127
95-9 * -16.60                         = 149
96-9 * 0.15                           = -1
97-9 * -0.01                          = 0
98-9 * 0                              = 0
99-9 * 0.00                           = 0
100-9 * -0                             = 0
101-9 * -0.00                          = 0
102-9 * 15151324141414.412312232141241 = -136361917272729
103-9 * -132132245132134.1515123765412 = 1189190206189207
104-9 * 141241241241241248267654747412 = -1271171171171171234408892726708
105-9 * -149143276547656984948124912   = 1342289488928912864533124208
106-9 * 0.1322135476547459213732911312 = -1
107-9 * -0.123912932193769965476541321 = 1
108
109Number "14.14" (scale 0)
11014.14 * 15                             = 212
11114.14 * -15                            = -212
11214.14 * 1                              = 14
11314.14 * -9                             = -127
11414.14 * 14.14                          = 199
11514.14 * -16.60                         = -234
11614.14 * 0.15                           = 2
11714.14 * -0.01                          = 0
11814.14 * 0                              = 0
11914.14 * 0.00                           = 0
12014.14 * -0                             = 0
12114.14 * -0.00                          = 0
12214.14 * 15151324141414.412312232141241 = 214239723359599
12314.14 * -132132245132134.1515123765412 = -1868349946168376
12414.14 * 141241241241241248267654747412 = 1997151151151151250504638128405
12514.14 * -149143276547656984948124912   = -2108885930383869767166486255
12614.14 * 0.1322135476547459213732911312 = 1
12714.14 * -0.123912932193769965476541321 = -1
128
129Number "-16.60" (scale 0)
130-16.60 * 15                             = -249
131-16.60 * -15                            = 249
132-16.60 * 1                              = -16
133-16.60 * -9                             = 149
134-16.60 * 14.14                          = -234
135-16.60 * -16.60                         = 275
136-16.60 * 0.15                           = -2
137-16.60 * -0.01                          = 0
138-16.60 * 0                              = 0
139-16.60 * 0.00                           = 0
140-16.60 * -0                             = 0
141-16.60 * -0.00                          = 0
142-16.60 * 15151324141414.412312232141241 = -251511980747479
143-16.60 * -132132245132134.1515123765412 = 2193395269193426
144-16.60 * 141241241241241248267654747412 = -2344604604604604721243068807039
145-16.60 * -149143276547656984948124912   = 2475778390691105950138873539
146-16.60 * 0.1322135476547459213732911312 = -2
147-16.60 * -0.123912932193769965476541321 = 2
148
149Number "0.15" (scale 0)
1500.15 * 15                             = 2
1510.15 * -15                            = -2
1520.15 * 1                              = 0
1530.15 * -9                             = -1
1540.15 * 14.14                          = 2
1550.15 * -16.60                         = -2
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 = 2272698621212
1630.15 * -132132245132134.1515123765412 = -19819836769820
1640.15 * 141241241241241248267654747412 = 21186186186186187240148212111
1650.15 * -149143276547656984948124912   = -22371491482148547742218736
1660.15 * 0.1322135476547459213732911312 = 0
1670.15 * -0.123912932193769965476541321 = 0
168
169Number "-0.01" (scale 0)
170-0.01 * 15                             = 0
171-0.01 * -15                            = 0
172-0.01 * 1                              = 0
173-0.01 * -9                             = 0
174-0.01 * 14.14                          = 0
175-0.01 * -16.60                         = 0
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 = -151513241414
183-0.01 * -132132245132134.1515123765412 = 1321322451321
184-0.01 * 141241241241241248267654747412 = -1412412412412412482676547474
185-0.01 * -149143276547656984948124912   = 1491432765476569849481249
186-0.01 * 0.1322135476547459213732911312 = 0
187-0.01 * -0.123912932193769965476541321 = 0
188
189Number "15" (scale 10)
19015 * 15                             = 225.0000000000
19115 * -15                            = -225.0000000000
19215 * 1                              = 15.0000000000
19315 * -9                             = -135.0000000000
19415 * 14.14                          = 212.1000000000
19515 * -16.60                         = -249.0000000000
19615 * 0.15                           = 2.2500000000
19715 * -0.01                          = -0.1500000000
19815 * 0                              = 0.0000000000
19915 * 0.00                           = 0.0000000000
20015 * -0                             = 0.0000000000
20115 * -0.00                          = 0.0000000000
20215 * 15151324141414.412312232141241 = 227269862121216.1846834821
20315 * -132132245132134.1515123765412 = -1981983676982012.2726856481
20415 * 141241241241241248267654747412 = 2118618618618618724014821211180.0000000000
20515 * -149143276547656984948124912   = -2237149148214854774221873680.0000000000
20615 * 0.1322135476547459213732911312 = 1.9832032148
20715 * -0.123912932193769965476541321 = -1.8586939829
208
209Number "-15" (scale 10)
210-15 * 15                             = -225.0000000000
211-15 * -15                            = 225.0000000000
212-15 * 1                              = -15.0000000000
213-15 * -9                             = 135.0000000000
214-15 * 14.14                          = -212.1000000000
215-15 * -16.60                         = 249.0000000000
216-15 * 0.15                           = -2.2500000000
217-15 * -0.01                          = 0.1500000000
218-15 * 0                              = 0.0000000000
219-15 * 0.00                           = 0.0000000000
220-15 * -0                             = 0.0000000000
221-15 * -0.00                          = 0.0000000000
222-15 * 15151324141414.412312232141241 = -227269862121216.1846834821
223-15 * -132132245132134.1515123765412 = 1981983676982012.2726856481
224-15 * 141241241241241248267654747412 = -2118618618618618724014821211180.0000000000
225-15 * -149143276547656984948124912   = 2237149148214854774221873680.0000000000
226-15 * 0.1322135476547459213732911312 = -1.9832032148
227-15 * -0.123912932193769965476541321 = 1.8586939829
228
229Number "1" (scale 10)
2301 * 15                             = 15.0000000000
2311 * -15                            = -15.0000000000
2321 * 1                              = 1.0000000000
2331 * -9                             = -9.0000000000
2341 * 14.14                          = 14.1400000000
2351 * -16.60                         = -16.6000000000
2361 * 0.15                           = 0.1500000000
2371 * -0.01                          = -0.0100000000
2381 * 0                              = 0.0000000000
2391 * 0.00                           = 0.0000000000
2401 * -0                             = 0.0000000000
2411 * -0.00                          = 0.0000000000
2421 * 15151324141414.412312232141241 = 15151324141414.4123122321
2431 * -132132245132134.1515123765412 = -132132245132134.1515123765
2441 * 141241241241241248267654747412 = 141241241241241248267654747412.0000000000
2451 * -149143276547656984948124912   = -149143276547656984948124912.0000000000
2461 * 0.1322135476547459213732911312 = 0.1322135476
2471 * -0.123912932193769965476541321 = -0.1239129321
248
249Number "-9" (scale 10)
250-9 * 15                             = -135.0000000000
251-9 * -15                            = 135.0000000000
252-9 * 1                              = -9.0000000000
253-9 * -9                             = 81.0000000000
254-9 * 14.14                          = -127.2600000000
255-9 * -16.60                         = 149.4000000000
256-9 * 0.15                           = -1.3500000000
257-9 * -0.01                          = 0.0900000000
258-9 * 0                              = 0.0000000000
259-9 * 0.00                           = 0.0000000000
260-9 * -0                             = 0.0000000000
261-9 * -0.00                          = 0.0000000000
262-9 * 15151324141414.412312232141241 = -136361917272729.7108100892
263-9 * -132132245132134.1515123765412 = 1189190206189207.3636113888
264-9 * 141241241241241248267654747412 = -1271171171171171234408892726708.0000000000
265-9 * -149143276547656984948124912   = 1342289488928912864533124208.0000000000
266-9 * 0.1322135476547459213732911312 = -1.1899219288
267-9 * -0.123912932193769965476541321 = 1.1152163897
268
269Number "14.14" (scale 10)
27014.14 * 15                             = 212.1000000000
27114.14 * -15                            = -212.1000000000
27214.14 * 1                              = 14.1400000000
27314.14 * -9                             = -127.2600000000
27414.14 * 14.14                          = 199.9396000000
27514.14 * -16.60                         = -234.7240000000
27614.14 * 0.15                           = 2.1210000000
27714.14 * -0.01                          = -0.1414000000
27814.14 * 0                              = 0.0000000000
27914.14 * 0.00                           = 0.0000000000
28014.14 * -0                             = 0.0000000000
28114.14 * -0.00                          = 0.0000000000
28214.14 * 15151324141414.412312232141241 = 214239723359599.7900949624
28314.14 * -132132245132134.1515123765412 = -1868349946168376.9023850042
28414.14 * 141241241241241248267654747412 = 1997151151151151250504638128405.6800000000
28514.14 * -149143276547656984948124912   = -2108885930383869767166486255.6800000000
28614.14 * 0.1322135476547459213732911312 = 1.8694995638
28714.14 * -0.123912932193769965476541321 = -1.7521288612
288
289Number "-16.60" (scale 10)
290-16.60 * 15                             = -249.0000000000
291-16.60 * -15                            = 249.0000000000
292-16.60 * 1                              = -16.6000000000
293-16.60 * -9                             = 149.4000000000
294-16.60 * 14.14                          = -234.7240000000
295-16.60 * -16.60                         = 275.5600000000
296-16.60 * 0.15                           = -2.4900000000
297-16.60 * -0.01                          = 0.1660000000
298-16.60 * 0                              = 0.0000000000
299-16.60 * 0.00                           = 0.0000000000
300-16.60 * -0                             = 0.0000000000
301-16.60 * -0.00                          = 0.0000000000
302-16.60 * 15151324141414.412312232141241 = -251511980747479.2443830535
303-16.60 * -132132245132134.1515123765412 = 2193395269193426.9151054505
304-16.60 * 141241241241241248267654747412 = -2344604604604604721243068807039.2000000000
305-16.60 * -149143276547656984948124912   = 2475778390691105950138873539.2000000000
306-16.60 * 0.1322135476547459213732911312 = -2.1947448910
307-16.60 * -0.123912932193769965476541321 = 2.0569546744
308
309Number "0.15" (scale 10)
3100.15 * 15                             = 2.2500000000
3110.15 * -15                            = -2.2500000000
3120.15 * 1                              = 0.1500000000
3130.15 * -9                             = -1.3500000000
3140.15 * 14.14                          = 2.1210000000
3150.15 * -16.60                         = -2.4900000000
3160.15 * 0.15                           = 0.0225000000
3170.15 * -0.01                          = -0.0015000000
3180.15 * 0                              = 0.0000000000
3190.15 * 0.00                           = 0.0000000000
3200.15 * -0                             = 0.0000000000
3210.15 * -0.00                          = 0.0000000000
3220.15 * 15151324141414.412312232141241 = 2272698621212.1618468348
3230.15 * -132132245132134.1515123765412 = -19819836769820.1227268564
3240.15 * 141241241241241248267654747412 = 21186186186186187240148212111.8000000000
3250.15 * -149143276547656984948124912   = -22371491482148547742218736.8000000000
3260.15 * 0.1322135476547459213732911312 = 0.0198320321
3270.15 * -0.123912932193769965476541321 = -0.0185869398
328
329Number "-0.01" (scale 10)
330-0.01 * 15                             = -0.1500000000
331-0.01 * -15                            = 0.1500000000
332-0.01 * 1                              = -0.0100000000
333-0.01 * -9                             = 0.0900000000
334-0.01 * 14.14                          = -0.1414000000
335-0.01 * -16.60                         = 0.1660000000
336-0.01 * 0.15                           = -0.0015000000
337-0.01 * -0.01                          = 0.0001000000
338-0.01 * 0                              = 0.0000000000
339-0.01 * 0.00                           = 0.0000000000
340-0.01 * -0                             = 0.0000000000
341-0.01 * -0.00                          = 0.0000000000
342-0.01 * 15151324141414.412312232141241 = -151513241414.1441231223
343-0.01 * -132132245132134.1515123765412 = 1321322451321.3415151237
344-0.01 * 141241241241241248267654747412 = -1412412412412412482676547474.1200000000
345-0.01 * -149143276547656984948124912   = 1491432765476569849481249.1200000000
346-0.01 * 0.1322135476547459213732911312 = -0.0013221354
347-0.01 * -0.123912932193769965476541321 = 0.0012391293
348