xref: /php-src/ext/bcmath/tests/number/methods/mul.phpt (revision fad899e5)
1--TEST--
2BcMath\Number mul()
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} * {$value2}: {$type}\n";
25        $ret = $num->mul($value2);
26        var_dump($ret);
27        echo "\n";
28    }
29}
30?>
31--EXPECT--
32100.012 * 100: int
33object(BcMath\Number)#4 (2) {
34  ["value"]=>
35  string(9) "10001.200"
36  ["scale"]=>
37  int(3)
38}
39
40100.012 * -30: int
41object(BcMath\Number)#5 (2) {
42  ["value"]=>
43  string(9) "-3000.360"
44  ["scale"]=>
45  int(3)
46}
47
48100.012 * -20: string
49object(BcMath\Number)#4 (2) {
50  ["value"]=>
51  string(9) "-2000.240"
52  ["scale"]=>
53  int(3)
54}
55
56100.012 * 0.01: string
57object(BcMath\Number)#5 (2) {
58  ["value"]=>
59  string(7) "1.00012"
60  ["scale"]=>
61  int(5)
62}
63
64100.012 * -0.40: string
65object(BcMath\Number)#4 (2) {
66  ["value"]=>
67  string(9) "-40.00480"
68  ["scale"]=>
69  int(5)
70}
71
72100.012 * 80.3: object
73object(BcMath\Number)#5 (2) {
74  ["value"]=>
75  string(9) "8030.9636"
76  ["scale"]=>
77  int(4)
78}
79
80100.012 * -50.6: object
81object(BcMath\Number)#4 (2) {
82  ["value"]=>
83  string(10) "-5060.6072"
84  ["scale"]=>
85  int(4)
86}
87
88-100.012 * 100: int
89object(BcMath\Number)#3 (2) {
90  ["value"]=>
91  string(10) "-10001.200"
92  ["scale"]=>
93  int(3)
94}
95
96-100.012 * -30: int
97object(BcMath\Number)#4 (2) {
98  ["value"]=>
99  string(8) "3000.360"
100  ["scale"]=>
101  int(3)
102}
103
104-100.012 * -20: string
105object(BcMath\Number)#3 (2) {
106  ["value"]=>
107  string(8) "2000.240"
108  ["scale"]=>
109  int(3)
110}
111
112-100.012 * 0.01: string
113object(BcMath\Number)#4 (2) {
114  ["value"]=>
115  string(8) "-1.00012"
116  ["scale"]=>
117  int(5)
118}
119
120-100.012 * -0.40: string
121object(BcMath\Number)#3 (2) {
122  ["value"]=>
123  string(8) "40.00480"
124  ["scale"]=>
125  int(5)
126}
127
128-100.012 * 80.3: object
129object(BcMath\Number)#4 (2) {
130  ["value"]=>
131  string(10) "-8030.9636"
132  ["scale"]=>
133  int(4)
134}
135
136-100.012 * -50.6: object
137object(BcMath\Number)#3 (2) {
138  ["value"]=>
139  string(9) "5060.6072"
140  ["scale"]=>
141  int(4)
142}
143