xref: /PHP-8.3/ext/bcmath/tests/bcdiv.phpt (revision ee226128)
1--TEST--
2bcdiv() function
3--EXTENSIONS--
4bcmath
5--INI--
6bcmath.scale=0
7--FILE--
8<?php
9require(__DIR__ . "/run_bcmath_tests_function.inc");
10
11$dividends = ["15", "-15", "1", "-9", "14.14", "-16.60", "0.15", "-0.01"];
12$divisors = array_merge($dividends, [
13    "15151324141414.412312232141241",
14    "-132132245132134.1515123765412",
15    "141241241241241248267654747412",
16    "-149143276547656984948124912",
17    "0.1322135476547459213732911312",
18    "-0.123912932193769965476541321",
19]);
20
21run_bcmath_tests($dividends, $divisors, "/", bcdiv(...));
22
23?>
24--EXPECT--
25Number "15" (scale 0)
2615 / 15                             = 1
2715 / -15                            = -1
2815 / 1                              = 15
2915 / -9                             = -1
3015 / 14.14                          = 1
3115 / -16.60                         = 0
3215 / 0.15                           = 100
3315 / -0.01                          = -1500
3415 / 15151324141414.412312232141241 = 0
3515 / -132132245132134.1515123765412 = 0
3615 / 141241241241241248267654747412 = 0
3715 / -149143276547656984948124912   = 0
3815 / 0.1322135476547459213732911312 = 113
3915 / -0.123912932193769965476541321 = -121
40
41Number "-15" (scale 0)
42-15 / 15                             = -1
43-15 / -15                            = 1
44-15 / 1                              = -15
45-15 / -9                             = 1
46-15 / 14.14                          = -1
47-15 / -16.60                         = 0
48-15 / 0.15                           = -100
49-15 / -0.01                          = 1500
50-15 / 15151324141414.412312232141241 = 0
51-15 / -132132245132134.1515123765412 = 0
52-15 / 141241241241241248267654747412 = 0
53-15 / -149143276547656984948124912   = 0
54-15 / 0.1322135476547459213732911312 = -113
55-15 / -0.123912932193769965476541321 = 121
56
57Number "1" (scale 0)
581 / 15                             = 0
591 / -15                            = 0
601 / 1                              = 1
611 / -9                             = 0
621 / 14.14                          = 0
631 / -16.60                         = 0
641 / 0.15                           = 6
651 / -0.01                          = -100
661 / 15151324141414.412312232141241 = 0
671 / -132132245132134.1515123765412 = 0
681 / 141241241241241248267654747412 = 0
691 / -149143276547656984948124912   = 0
701 / 0.1322135476547459213732911312 = 7
711 / -0.123912932193769965476541321 = -8
72
73Number "-9" (scale 0)
74-9 / 15                             = 0
75-9 / -15                            = 0
76-9 / 1                              = -9
77-9 / -9                             = 1
78-9 / 14.14                          = 0
79-9 / -16.60                         = 0
80-9 / 0.15                           = -60
81-9 / -0.01                          = 900
82-9 / 15151324141414.412312232141241 = 0
83-9 / -132132245132134.1515123765412 = 0
84-9 / 141241241241241248267654747412 = 0
85-9 / -149143276547656984948124912   = 0
86-9 / 0.1322135476547459213732911312 = -68
87-9 / -0.123912932193769965476541321 = 72
88
89Number "14.14" (scale 0)
9014.14 / 15                             = 0
9114.14 / -15                            = 0
9214.14 / 1                              = 14
9314.14 / -9                             = -1
9414.14 / 14.14                          = 1
9514.14 / -16.60                         = 0
9614.14 / 0.15                           = 94
9714.14 / -0.01                          = -1414
9814.14 / 15151324141414.412312232141241 = 0
9914.14 / -132132245132134.1515123765412 = 0
10014.14 / 141241241241241248267654747412 = 0
10114.14 / -149143276547656984948124912   = 0
10214.14 / 0.1322135476547459213732911312 = 106
10314.14 / -0.123912932193769965476541321 = -114
104
105Number "-16.60" (scale 0)
106-16.60 / 15                             = -1
107-16.60 / -15                            = 1
108-16.60 / 1                              = -16
109-16.60 / -9                             = 1
110-16.60 / 14.14                          = -1
111-16.60 / -16.60                         = 1
112-16.60 / 0.15                           = -110
113-16.60 / -0.01                          = 1660
114-16.60 / 15151324141414.412312232141241 = 0
115-16.60 / -132132245132134.1515123765412 = 0
116-16.60 / 141241241241241248267654747412 = 0
117-16.60 / -149143276547656984948124912   = 0
118-16.60 / 0.1322135476547459213732911312 = -125
119-16.60 / -0.123912932193769965476541321 = 133
120
121Number "0.15" (scale 0)
1220.15 / 15                             = 0
1230.15 / -15                            = 0
1240.15 / 1                              = 0
1250.15 / -9                             = 0
1260.15 / 14.14                          = 0
1270.15 / -16.60                         = 0
1280.15 / 0.15                           = 1
1290.15 / -0.01                          = -15
1300.15 / 15151324141414.412312232141241 = 0
1310.15 / -132132245132134.1515123765412 = 0
1320.15 / 141241241241241248267654747412 = 0
1330.15 / -149143276547656984948124912   = 0
1340.15 / 0.1322135476547459213732911312 = 1
1350.15 / -0.123912932193769965476541321 = -1
136
137Number "-0.01" (scale 0)
138-0.01 / 15                             = 0
139-0.01 / -15                            = 0
140-0.01 / 1                              = 0
141-0.01 / -9                             = 0
142-0.01 / 14.14                          = 0
143-0.01 / -16.60                         = 0
144-0.01 / 0.15                           = 0
145-0.01 / -0.01                          = 1
146-0.01 / 15151324141414.412312232141241 = 0
147-0.01 / -132132245132134.1515123765412 = 0
148-0.01 / 141241241241241248267654747412 = 0
149-0.01 / -149143276547656984948124912   = 0
150-0.01 / 0.1322135476547459213732911312 = 0
151-0.01 / -0.123912932193769965476541321 = 0
152
153Number "15" (scale 10)
15415 / 15                             = 1.0000000000
15515 / -15                            = -1.0000000000
15615 / 1                              = 15.0000000000
15715 / -9                             = -1.6666666666
15815 / 14.14                          = 1.0608203677
15915 / -16.60                         = -0.9036144578
16015 / 0.15                           = 100.0000000000
16115 / -0.01                          = -1500.0000000000
16215 / 15151324141414.412312232141241 = 0.0000000000
16315 / -132132245132134.1515123765412 = 0.0000000000
16415 / 141241241241241248267654747412 = 0.0000000000
16515 / -149143276547656984948124912   = 0.0000000000
16615 / 0.1322135476547459213732911312 = 113.4528213339
16715 / -0.123912932193769965476541321 = -121.0527402946
168
169Number "-15" (scale 10)
170-15 / 15                             = -1.0000000000
171-15 / -15                            = 1.0000000000
172-15 / 1                              = -15.0000000000
173-15 / -9                             = 1.6666666666
174-15 / 14.14                          = -1.0608203677
175-15 / -16.60                         = 0.9036144578
176-15 / 0.15                           = -100.0000000000
177-15 / -0.01                          = 1500.0000000000
178-15 / 15151324141414.412312232141241 = 0.0000000000
179-15 / -132132245132134.1515123765412 = 0.0000000000
180-15 / 141241241241241248267654747412 = 0.0000000000
181-15 / -149143276547656984948124912   = 0.0000000000
182-15 / 0.1322135476547459213732911312 = -113.4528213339
183-15 / -0.123912932193769965476541321 = 121.0527402946
184
185Number "1" (scale 10)
1861 / 15                             = 0.0666666666
1871 / -15                            = -0.0666666666
1881 / 1                              = 1.0000000000
1891 / -9                             = -0.1111111111
1901 / 14.14                          = 0.0707213578
1911 / -16.60                         = -0.0602409638
1921 / 0.15                           = 6.6666666666
1931 / -0.01                          = -100.0000000000
1941 / 15151324141414.412312232141241 = 0.0000000000
1951 / -132132245132134.1515123765412 = 0.0000000000
1961 / 141241241241241248267654747412 = 0.0000000000
1971 / -149143276547656984948124912   = 0.0000000000
1981 / 0.1322135476547459213732911312 = 7.5635214222
1991 / -0.123912932193769965476541321 = -8.0701826863
200
201Number "-9" (scale 10)
202-9 / 15                             = -0.6000000000
203-9 / -15                            = 0.6000000000
204-9 / 1                              = -9.0000000000
205-9 / -9                             = 1.0000000000
206-9 / 14.14                          = -0.6364922206
207-9 / -16.60                         = 0.5421686746
208-9 / 0.15                           = -60.0000000000
209-9 / -0.01                          = 900.0000000000
210-9 / 15151324141414.412312232141241 = 0.0000000000
211-9 / -132132245132134.1515123765412 = 0.0000000000
212-9 / 141241241241241248267654747412 = 0.0000000000
213-9 / -149143276547656984948124912   = 0.0000000000
214-9 / 0.1322135476547459213732911312 = -68.0716928003
215-9 / -0.123912932193769965476541321 = 72.6316441767
216
217Number "14.14" (scale 10)
21814.14 / 15                             = 0.9426666666
21914.14 / -15                            = -0.9426666666
22014.14 / 1                              = 14.1400000000
22114.14 / -9                             = -1.5711111111
22214.14 / 14.14                          = 1.0000000000
22314.14 / -16.60                         = -0.8518072289
22414.14 / 0.15                           = 94.2666666666
22514.14 / -0.01                          = -1414.0000000000
22614.14 / 15151324141414.412312232141241 = 0.0000000000
22714.14 / -132132245132134.1515123765412 = 0.0000000000
22814.14 / 141241241241241248267654747412 = 0.0000000000
22914.14 / -149143276547656984948124912   = 0.0000000000
23014.14 / 0.1322135476547459213732911312 = 106.9481929107
23114.14 / -0.123912932193769965476541321 = -114.1123831844
232
233Number "-16.60" (scale 10)
234-16.60 / 15                             = -1.1066666666
235-16.60 / -15                            = 1.1066666666
236-16.60 / 1                              = -16.6000000000
237-16.60 / -9                             = 1.8444444444
238-16.60 / 14.14                          = -1.1739745403
239-16.60 / -16.60                         = 1.0000000000
240-16.60 / 0.15                           = -110.6666666666
241-16.60 / -0.01                          = 1660.0000000000
242-16.60 / 15151324141414.412312232141241 = 0.0000000000
243-16.60 / -132132245132134.1515123765412 = 0.0000000000
244-16.60 / 141241241241241248267654747412 = 0.0000000000
245-16.60 / -149143276547656984948124912   = 0.0000000000
246-16.60 / 0.1322135476547459213732911312 = -125.5544556095
247-16.60 / -0.123912932193769965476541321 = 133.9650325927
248
249Number "0.15" (scale 10)
2500.15 / 15                             = 0.0100000000
2510.15 / -15                            = -0.0100000000
2520.15 / 1                              = 0.1500000000
2530.15 / -9                             = -0.0166666666
2540.15 / 14.14                          = 0.0106082036
2550.15 / -16.60                         = -0.0090361445
2560.15 / 0.15                           = 1.0000000000
2570.15 / -0.01                          = -15.0000000000
2580.15 / 15151324141414.412312232141241 = 0.0000000000
2590.15 / -132132245132134.1515123765412 = 0.0000000000
2600.15 / 141241241241241248267654747412 = 0.0000000000
2610.15 / -149143276547656984948124912   = 0.0000000000
2620.15 / 0.1322135476547459213732911312 = 1.1345282133
2630.15 / -0.123912932193769965476541321 = -1.2105274029
264
265Number "-0.01" (scale 10)
266-0.01 / 15                             = -0.0006666666
267-0.01 / -15                            = 0.0006666666
268-0.01 / 1                              = -0.0100000000
269-0.01 / -9                             = 0.0011111111
270-0.01 / 14.14                          = -0.0007072135
271-0.01 / -16.60                         = 0.0006024096
272-0.01 / 0.15                           = -0.0666666666
273-0.01 / -0.01                          = 1.0000000000
274-0.01 / 15151324141414.412312232141241 = 0.0000000000
275-0.01 / -132132245132134.1515123765412 = 0.0000000000
276-0.01 / 141241241241241248267654747412 = 0.0000000000
277-0.01 / -149143276547656984948124912   = 0.0000000000
278-0.01 / 0.1322135476547459213732911312 = -0.0756352142
279-0.01 / -0.123912932193769965476541321 = 0.0807018268
280