1--TEST--
2BcMath\Number sqrt() with scale
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$radicants = [
9    "0",
10    "0.00",
11    "-0",
12    "-0.00",
13    "15151324141414.412312232141241",
14    "141241241241241248267654747412",
15    "0.1322135476547459213732911312",
16    "14.14",
17    "0.15",
18    "15",
19    "1",
20];
21$scales = [0, 10];
22
23foreach ($scales as $scale) {
24    foreach ($radicants as $radicant) {
25        $func_ret = bcsqrt($radicant, $scale);
26        $method_ret = (new BcMath\Number($radicant))->sqrt($scale);
27        if ($method_ret->compare($func_ret) !== 0) {
28            echo "Result is incorrect.\n";
29            var_dump($radicant, $scale, $func_ret, $method_ret, ((string) $method_ret) === $func_ret);
30        }
31    }
32}
33echo 'done!';
34?>
35--EXPECT--
36done!
37