diff --git a/reference/bc/bcmath/number/sqrt.xml b/reference/bc/bcmath/number/sqrt.xml new file mode 100644 index 000000000000..84b565dfa7e2 --- /dev/null +++ b/reference/bc/bcmath/number/sqrt.xml @@ -0,0 +1,141 @@ + + + + BcMath\Number::sqrt + Gets the square root of an arbitrary precision number + + + + &reftitle.description; + + public BcMath\NumberBcMath\Number::sqrt + intnullscale&null; + + + Return the square root of this object. + + + + + &reftitle.parameters; + + &bc.number.scale.description; + + + + + &reftitle.returnvalues; + + Returns the square root as a new BcMath\Number object. + + + + + &reftitle.errors; + + This method throws a ValueError in the following cases: + + This object is a negative value + scale is outside the valid range + BcMath\Number::scale of the result object is outside the valid range + + + + + + + + + When the BcMath\Number::scale of the result object is automatically set, + the BcMath\Number::scale of this object is used. However, in cases such + as indivisible division, the BcMath\Number::scale of the result is expanded. + Expansion is done only as needed, up to a maximum of +10. + + + That is, if the BcMath\Number::scale of this object is 5, + the BcMath\Number::scale of the result is between 5 and + 15. + + + This behavior is the same as BcMath\Number::div, so please see that for details. + + + + + &reftitle.examples; + + <methodname>BcMath\Number::sqrt</methodname> example + +sqrt(), + new BcMath\Number('2')->sqrt(3), + new BcMath\Number('4')->sqrt(), + new BcMath\Number('4')->sqrt(3), +); +?> +]]> + + &example.outputs; + + + string(12) "1.4142135623" + ["scale"]=> + int(10) +} +object(BcMath\Number)#3 (2) { + ["value"]=> + string(5) "1.414" + ["scale"]=> + int(3) +} +object(BcMath\Number)#4 (2) { + ["value"]=> + string(1) "2" + ["scale"]=> + int(0) +} +object(BcMath\Number)#5 (2) { + ["value"]=> + string(5) "2.000" + ["scale"]=> + int(3) +} +]]> + + + + + + &reftitle.seealso; + + bcsqrt + BcMath\Number::div + BcMath\Number::pow + + + + + diff --git a/reference/bc/functions/bcsqrt.xml b/reference/bc/functions/bcsqrt.xml index 4da28a897f1d..077c653e3105 100644 --- a/reference/bc/functions/bcsqrt.xml +++ b/reference/bc/functions/bcsqrt.xml @@ -113,6 +113,7 @@ echo bcsqrt('2', 3); // 1.414 bcpow + BcMath\Number::sqrt