|
BcMath\Number::divmod任意精度数値の商と剰余を取得する 説明
public array BcMath\Number::divmod(BcMath\Numberstringint
$num, intnull $scale = null)
$this を パラメータ
戻り値1つ目の要素に商として新しい BcMath\Number オブジェクトが、 2つ目の要素に剰余として新しい BcMath\Number オブジェクトが格納された配列を返します。
商は常に整数値となるため、商オブジェクトの BcMath\Number::scale は
つまり、2つの値の BcMath\Number::scale がそれぞれ エラー / 例外このメソッドは、以下の場合に ValueError をスローします:
このメソッドは、 例例1 BcMath\Number::divmod で 上の例の出力は以下となります。
8.3 / 2.22
object(BcMath\Number)#3 (2) {
["value"]=>
string(1) "3"
["scale"]=>
int(0)
}
object(BcMath\Number)#4 (2) {
["value"]=>
string(4) "1.34"
["scale"]=>
int(2)
}
8.3 / 8.3
object(BcMath\Number)#2 (2) {
["value"]=>
string(1) "1"
["scale"]=>
int(0)
}
object(BcMath\Number)#5 (2) {
["value"]=>
string(3) "0.0"
["scale"]=>
int(1)
}
10 / -3
object(BcMath\Number)#3 (2) {
["value"]=>
string(2) "-3"
["scale"]=>
int(0)
}
object(BcMath\Number)#1 (2) {
["value"]=>
string(1) "1"
["scale"]=>
int(0)
}
例2 BcMath\Number::divmod で 上の例の出力は以下となります。
8.3 / 2.22
object(BcMath\Number)#3 (2) {
["value"]=>
string(1) "3"
["scale"]=>
int(0)
}
object(BcMath\Number)#4 (2) {
["value"]=>
string(3) "1.3"
["scale"]=>
int(1)
}
8.3 / 8.3
object(BcMath\Number)#2 (2) {
["value"]=>
string(1) "1"
["scale"]=>
int(0)
}
object(BcMath\Number)#5 (2) {
["value"]=>
string(6) "0.0000"
["scale"]=>
int(4)
}
10 / -3
object(BcMath\Number)#3 (2) {
["value"]=>
string(2) "-3"
["scale"]=>
int(0)
}
object(BcMath\Number)#1 (2) {
["value"]=>
string(7) "1.00000"
["scale"]=>
int(5)
}
参考
|