|
BcMath\Number::sqrt任意精度数値の平方根を取得する 説明
public BcMath\Number BcMath\Number::sqrt(intnull
$scale = null )$this の平方根を返します。 パラメータ
戻り値平方根を新しい BcMath\Number オブジェクトとして返します。
計算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、$this の
BcMath\Number::scale が使用されます。ただし、割り切れない除算が発生した場合は、
計算結果オブジェクトの BcMath\Number::scale が拡張されます。
拡張は必要に応じてのみ行われ、最大で
つまり、$this の BcMath\Number::scale が エラー / 例外このメソッドは、以下の場合に ValueError をスローします:
例例1 BcMath\Number::sqrt の例
上の例の出力は以下となります。 object(BcMath\Number)#2 (2) { ["value"]=> 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) } 参考
|