1--TEST--
2BcMath\Number sub() with scale
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$scales = [0, 1, 2, 3, 4];
9
10$values1 = ['100.012', '-100.012'];
11
12$values2 = [
13    [100, 'int'],
14    [-30, 'int'],
15    ['100.012', 'string'],
16    ['-100.012', 'string'],
17    ['-20', 'string'],
18    ['0.01', 'string'],
19    ['-0.40', 'string'],
20    [new BcMath\Number('80.3'), 'object'],
21    [new BcMath\Number('-50.6'), 'object'],
22];
23
24foreach ($scales as $scale) {
25    foreach ($values1 as $value1) {
26        $num = new BcMath\Number($value1);
27
28        foreach ($values2 as [$value2, $type]) {
29            $func_ret = bcsub($value1, (string) $value2, $scale);
30            $method_ret = $num->sub($value2, $scale);
31            if ($method_ret->compare($func_ret) !== 0) {
32                echo "Result is incorrect.\n";
33                var_dump($value1, $value2, $scale, $func_ret, $method_ret);
34            }
35        }
36    }
37}
38echo 'done!';
39?>
40--EXPECT--
41done!
42