1--TEST--
2BcMath\Number add string by operator
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$values = [
9    100,
10    '-20',
11    '0.01',
12    '-0.40',
13];
14
15foreach ($values as $value1) {
16    $num1 = new BcMath\Number($value1);
17
18    foreach ($values as $value2) {
19        echo "{$value1} + {$value2}\n";
20        $ret = $num1 + ((string) $value2);
21        $ret2 = ((string) $value1) + (new BcMath\Number($value2));
22        if ($ret->compare($ret2) !== 0) {
23            echo "Result is incorrect.\n";
24        }
25        var_dump($ret);
26        echo "\n";
27    }
28}
29?>
30--EXPECT--
31100 + 100
32object(BcMath\Number)#2 (2) {
33  ["value"]=>
34  string(3) "200"
35  ["scale"]=>
36  int(0)
37}
38
39100 + -20
40object(BcMath\Number)#3 (2) {
41  ["value"]=>
42  string(2) "80"
43  ["scale"]=>
44  int(0)
45}
46
47100 + 0.01
48object(BcMath\Number)#4 (2) {
49  ["value"]=>
50  string(6) "100.01"
51  ["scale"]=>
52  int(2)
53}
54
55100 + -0.40
56object(BcMath\Number)#5 (2) {
57  ["value"]=>
58  string(5) "99.60"
59  ["scale"]=>
60  int(2)
61}
62
63-20 + 100
64object(BcMath\Number)#1 (2) {
65  ["value"]=>
66  string(2) "80"
67  ["scale"]=>
68  int(0)
69}
70
71-20 + -20
72object(BcMath\Number)#3 (2) {
73  ["value"]=>
74  string(3) "-40"
75  ["scale"]=>
76  int(0)
77}
78
79-20 + 0.01
80object(BcMath\Number)#4 (2) {
81  ["value"]=>
82  string(6) "-19.99"
83  ["scale"]=>
84  int(2)
85}
86
87-20 + -0.40
88object(BcMath\Number)#5 (2) {
89  ["value"]=>
90  string(6) "-20.40"
91  ["scale"]=>
92  int(2)
93}
94
950.01 + 100
96object(BcMath\Number)#2 (2) {
97  ["value"]=>
98  string(6) "100.01"
99  ["scale"]=>
100  int(2)
101}
102
1030.01 + -20
104object(BcMath\Number)#3 (2) {
105  ["value"]=>
106  string(6) "-19.99"
107  ["scale"]=>
108  int(2)
109}
110
1110.01 + 0.01
112object(BcMath\Number)#4 (2) {
113  ["value"]=>
114  string(4) "0.02"
115  ["scale"]=>
116  int(2)
117}
118
1190.01 + -0.40
120object(BcMath\Number)#5 (2) {
121  ["value"]=>
122  string(5) "-0.39"
123  ["scale"]=>
124  int(2)
125}
126
127-0.40 + 100
128object(BcMath\Number)#1 (2) {
129  ["value"]=>
130  string(5) "99.60"
131  ["scale"]=>
132  int(2)
133}
134
135-0.40 + -20
136object(BcMath\Number)#3 (2) {
137  ["value"]=>
138  string(6) "-20.40"
139  ["scale"]=>
140  int(2)
141}
142
143-0.40 + 0.01
144object(BcMath\Number)#4 (2) {
145  ["value"]=>
146  string(5) "-0.39"
147  ["scale"]=>
148  int(2)
149}
150
151-0.40 + -0.40
152object(BcMath\Number)#5 (2) {
153  ["value"]=>
154  string(5) "-0.80"
155  ["scale"]=>
156  int(2)
157}
158