|
BcMath\Number::add任意精度の数値を加算する 説明
public BcMath\Number BcMath\Number::add(BcMath\Numberstringint
$num , intnull $scale = null )
$this と パラメータ
戻り値加算結果を新しい BcMath\Number オブジェクトとして返します。 加算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、加算に使用する2つの数値のうち、 大きい方の BcMath\Number::scale が使用されます。
つまり、2つの値の BcMath\Number::scale がそれぞれ エラー / 例外このメソッドは、以下の場合に ValueError をスローします:
例例1 BcMath\Number::add で
上の例の出力は以下となります。 object(BcMath\Number)#1 (2) { ["value"]=> string(5) "1.234" ["scale"]=> int(3) } object(BcMath\Number)#3 (2) { ["value"]=> string(7) "3.57967" ["scale"]=> int(5) } object(BcMath\Number)#2 (2) { ["value"]=> string(6) "-2.222" ["scale"]=> int(3) } object(BcMath\Number)#4 (2) { ["value"]=> string(5) "8.234" ["scale"]=> int(3) } 例2 BcMath\Number::add で
上の例の出力は以下となります。 object(BcMath\Number)#1 (2) { ["value"]=> string(5) "1.234" ["scale"]=> int(3) } object(BcMath\Number)#3 (2) { ["value"]=> string(3) "3.5" ["scale"]=> int(1) } object(BcMath\Number)#2 (2) { ["value"]=> string(13) "-2.2220000000" ["scale"]=> int(10) } object(BcMath\Number)#4 (2) { ["value"]=> string(1) "8" ["scale"]=> int(0) } 参考
|