|
BcMath\Number::div任意精度数値の除算を行う 説明
public BcMath\Number BcMath\Number::div(BcMath\Numberstringint
$num , intnull $scale = null )
$this を パラメータ
戻り値除算結果を新しい BcMath\Number オブジェクトとして返します。
除算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、被除数の
BcMath\Number::scale が使用されます。ただし、割り切れない除算の場合は、
除算結果オブジェクトの BcMath\Number::scale が拡張されます。
拡張は必要に応じてのみ行われ、最大で
つまり、被除数の BcMath\Number::scale が
割り切れない除算の場合でも、除算結果オブジェクトの BcMath\Number::scale は常に エラー / 例外このメソッドは、以下の場合に ValueError をスローします:
このメソッドは、 例例1 BcMath\Number::div で
上の例の出力は以下となります。 object(BcMath\Number)#1 (2) { ["value"]=> string(5) "0.002" ["scale"]=> int(3) } object(BcMath\Number)#3 (2) { ["value"]=> string(5) "0.001" ["scale"]=> int(3) } object(BcMath\Number)#2 (2) { ["value"]=> string(16) "-0.0006666666666" ["scale"]=> int(13) } object(BcMath\Number)#4 (2) { ["value"]=> string(9) "0.0000625" ["scale"]=> int(7) } 例2 BcMath\Number::div で
上の例の出力は以下となります。 object(BcMath\Number)#1 (2) { ["value"]=> string(5) "0.002" ["scale"]=> int(3) } object(BcMath\Number)#3 (2) { ["value"]=> string(17) "0.001000000000000" ["scale"]=> int(15) } object(BcMath\Number)#2 (2) { ["value"]=> string(8) "-0.00066" ["scale"]=> int(5) } object(BcMath\Number)#4 (2) { ["value"]=> string(4) "0.00" ["scale"]=> int(2) } 例3 BcMath\Number::div の結果の BcMath\Number::scale が拡張される例
上の例の出力は以下となります。 object(BcMath\Number)#2 (2) { ["value"]=> string(13) "0.00000009999" ["scale"]=> int(11) } object(BcMath\Number)#3 (2) { ["value"]=> string(15) "0.0000000999900" ["scale"]=> int(13) } object(BcMath\Number)#4 (2) { ["value"]=> string(5) "0.000" ["scale"]=> int(3) } 参考
|