diff --git a/language-snippets.ent b/language-snippets.ent
index b748b5c6ec..fa38f0735d 100644
--- a/language-snippets.ent
+++ b/language-snippets.ent
@@ -1,6 +1,6 @@
-
+
@@ -2121,20 +2121,6 @@ PECL 拡張モジュールのインストール という章にありま
SQL セーフモード'>
-
-
-
- scale
-
-
- This parameter is used to set the number of digits after the decimal place in the result.
- If &null;, it will default to the default scale set with bcscale,
- or fallback to the value of the
- bcmath.scale INI directive.
-
-
-'>
-
-128 から 255 までの int を渡すと、ひとつの文字の ASCII 値とみなします
diff --git a/reference/bc/bcmath.number.xml b/reference/bc/bcmath.number.xml
new file mode 100644
index 0000000000..3d11c61dcc
--- /dev/null
+++ b/reference/bc/bcmath.number.xml
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+ BcMath\Number クラス
+ BcMath\Number
+
+
+
+ &reftitle.intro;
+
+ 任意精度数値のクラスです。
+ このオブジェクトは、オーバーロードされた
+ 算術演算子,
+ 比較演算子
+ をサポートしています。
+
+
+
+
+ このクラスは、&php.ini;で設定された
+ bcmath.scale
+ INI ディレクティブの影響を受けません。
+
+
+
+
+
+ オーバーロードされた演算子の動作は、対応するメソッドで
+ scale パラメータに &null; を指定した場合と同じです。
+
+
+
+
+
+ &reftitle.classsynopsis;
+
+
+
+ final
+ readonly
+ BcMath\Number
+
+
+
+ implements
+ Stringable
+
+
+ &Properties;
+
+ public
+ string
+ value
+
+
+ public
+ int
+ scale
+
+
+ &Methods;
+
+
+
+
+
+
+
+
+
+
+ &reftitle.properties;
+
+
+ value
+
+
+ 任意精度数値の文字表現。
+
+
+
+
+ scale
+
+
+ オブジェクトに設定されているスケールの値。
+ 計算メソッドで明示的に scale パラメータが設定されていない場合、
+ この値は自動的に計算されて設定されます。
+
+
+
+
+
+
+
+
+ &reference.bc.bcmath.entities.number;
+
+
+
diff --git a/reference/bc/bcmath/number/add.xml b/reference/bc/bcmath/number/add.xml
new file mode 100644
index 0000000000..e2546177c1
--- /dev/null
+++ b/reference/bc/bcmath/number/add.xml
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+ BcMath\Number::add
+ 任意精度の数値を加算する
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::add
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this と num を加算します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 加数を表す値。
+
+
+
+
+ scale
+
+
+ 計算結果オブジェクトの BcMath\Number::scale を明示的に指定します。
+ &null; の場合、計算結果の BcMath\Number::scale は自動的に設定されます。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 加算結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 加算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、加算に使用する2つの数値のうち、
+ 大きい方の BcMath\Number::scale が使用されます。
+
+
+ つまり、2つの値の BcMath\Number::scale がそれぞれ 2 と 5 の場合、
+ 加算結果オブジェクトの BcMath\Number::scale は 5 になります。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、以下の場合に ValueError をスローします:
+
+ num が、BCMath で有効でない数値形式の文字列である場合
+ scale が範囲外の値である場合
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::add で scale を指定しない例
+
+add(new BcMath\Number('2.34567'));
+$ret2 = $number->add('-3.456');
+$ret3 = $number->add(7);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+ BcMath\Number::add で scale を指定する例
+
+add(new BcMath\Number('2.34567'), 1);
+$ret2 = $number->add('-3.456', 10);
+$ret3 = $number->add(7, 0);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcadd
+ BcMath\Number::sub
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/ceil.xml b/reference/bc/bcmath/number/ceil.xml
new file mode 100644
index 0000000000..bf9c2820b7
--- /dev/null
+++ b/reference/bc/bcmath/number/ceil.xml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+ BcMath\Number::ceil
+ 任意精度数値を切り上げる
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::ceil
+
+
+
+ 必要に応じて $this を切り上げ、 $this の次に大きい整数値を返します。
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ 結果を新しい BcMath\Number オブジェクトとして返します。
+ 結果の BcMath\Number::scale は常に 0 になります。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::ceil の例
+
+ceil();
+$num2 = new BcMath\Number('9.999')->ceil();
+$num3 = new BcMath\Number('-3.14')->ceil();
+
+var_dump($num1, $num2, $num3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(1) "5"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(2) "10"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(2) "-3"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcceil
+ BcMath\Number::floor
+ BcMath\Number::round
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/compare.xml b/reference/bc/bcmath/number/compare.xml
new file mode 100644
index 0000000000..409fbf5eca
--- /dev/null
+++ b/reference/bc/bcmath/number/compare.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+ BcMath\Number::compare
+ 任意精度数値を比較する
+
+
+
+ &reftitle.description;
+
+ public intBcMath\Number::compare
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ 任意精度数値を比較します。
+ このメソッドは、 宇宙船演算子 と同じように動作します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 比較する値。
+
+
+
+
+ scale
+
+
+ 比較に使用する scale を指定します。
+ &null; の場合、比較にはすべての桁が使用されます。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 2つの値が等しい場合は 0、$this が num
+ より大きい場合は 1、小さければ -1 を返します。
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::compare で scale を指定しない例
+
+compare(new BcMath\Number('1.234')),
+ $number->compare('1.23400'),
+ $number->compare('1.23401'),
+ $number->compare(1),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+ BcMath\Number::compare で scale を指定する例
+
+compare(new BcMath\Number('1.299'), 1),
+ $number->compare('1.24', 2),
+ $number->compare('1.22', 2),
+ $number->compare(1, 0),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+
+ &reftitle.seealso;
+
+ bccomp
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/construct.xml b/reference/bc/bcmath/number/construct.xml
new file mode 100644
index 0000000000..e126528ea7
--- /dev/null
+++ b/reference/bc/bcmath/number/construct.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+ BcMath\Number::__construct
+ BcMath\Number オブジェクトを作成する
+
+
+
+ &reftitle.description;
+
+ public BcMath\Number::__construct
+ stringintnum
+
+
+ int もしくは string の値から BcMath\Number オブジェクトを作成します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ int もしくは string の値。
+ num が int の場合、BcMath\Number::scale
+ は常に 0 に設定されます。
+ num が string の場合、有効な BCMath 数値文字列である必要があり、
+ BcMath\Number::scale は自動的に文字列を解析して設定されます。
+
+
+
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、 num が string であり、BCMath で有効でない
+ 数値形式の文字列である場合、ValueError をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::__construct の例
+
+
+]]>
+
+ &example.outputs;
+
+
+ string(3) "100"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(4) "-200"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(6) "300.00"
+ ["scale"]=>
+ int(2)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::__serialize
+ BcMath\Number::__unserialize
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/div.xml b/reference/bc/bcmath/number/div.xml
new file mode 100644
index 0000000000..ffb8c279e7
--- /dev/null
+++ b/reference/bc/bcmath/number/div.xml
@@ -0,0 +1,246 @@
+
+
+
+
+
+
+ BcMath\Number::div
+ 任意精度数値の除算を行う
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::div
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this を num で割ります。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 除数を表す値。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 除算結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 除算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、被除数の
+ BcMath\Number::scale が使用されます。ただし、割り切れない除算の場合は、
+ 除算結果オブジェクトの BcMath\Number::scale が拡張されます。
+ 拡張は必要に応じてのみ行われ、最大で +10 まで拡張されます。
+
+
+ つまり、被除数の BcMath\Number::scale が 5 の場合、
+ 除算結果オブジェクトの BcMath\Number::scale は 5 から
+ 15 の間になります。
+
+
+ 割り切れない除算の場合でも、除算結果オブジェクトの BcMath\Number::scale は常に +10
+ まで拡張されるわけではありません。
+ 末尾が 0 である場合は拡張の必要がないと見なされるため、 BcMath\Number::scale
+ はその分だけ少なくなります。
+ また、最終的な BcMath\Number::scale は、拡張前の BcMath\Number::scale
+ よりも小さくなることはありません。
+ コード例 も参照してください。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、以下の場合に ValueError をスローします:
+
+ num が、BCMath で有効でない数値形式の文字列である場合
+ scale が範囲外の値である場合
+ 結果オブジェクトの BcMath\Number::scale が範囲外の値である場合
+
+
+
+ このメソッドは、 num が 0 である場合、
+ DivisionByZeroError 例外をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::div で scale を指定しない例
+
+div(new BcMath\Number('2.000'));
+$ret2 = $number->div('-3');
+$ret3 = $number->div(32);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+ BcMath\Number::div で scale を指定する例
+
+div(new BcMath\Number('2.000'), 15);
+$ret2 = $number->div('-3', 5);
+$ret3 = $number->div(32, 2);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+ BcMath\Number::div の結果の BcMath\Number::scale が拡張される例
+
+div('10001'),
+ new BcMath\Number('0.001')->div('10001', 13),
+ new BcMath\Number('0.001')->div('100000000000001'),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcdiv
+ BcMath\Number::divmod
+ BcMath\Number::mod
+ BcMath\Number::sqrt
+ BcMath\Number::pow
+ BcMath\Number::mul
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/divmod.xml b/reference/bc/bcmath/number/divmod.xml
new file mode 100644
index 0000000000..20c1e9b37a
--- /dev/null
+++ b/reference/bc/bcmath/number/divmod.xml
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+ BcMath\Number::divmod
+ 任意精度数値の商と剰余を取得する
+
+
+
+ &reftitle.description;
+
+ public arrayBcMath\Number::divmod
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this を num で割った商と剰余を取得します。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 1つ目の要素に商として新しい BcMath\Number オブジェクトが、
+ 2つ目の要素に剰余として新しい BcMath\Number オブジェクトが格納された配列を返します。
+
+
+ 商は常に整数値となるため、商オブジェクトの BcMath\Number::scale は scale
+ の指定に関わらず、常に 0 になります。
+
+
+ scale を明示的に指定した場合、剰余オブジェクトの BcMath\Number::scale は指定された値になります。
+ 剰余オブジェクトの BcMath\Number::scale が自動的に設定される場合、計算に使用された2つの数値のうち、大きい方の
+ BcMath\Number::scale が使用されます。
+
+
+ つまり、2つの値の BcMath\Number::scale がそれぞれ 2 と 5 の場合、
+ 剰余オブジェクトの BcMath\Number::scale は 5 になります。
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::divmod で scale を指定しない例
+
+divmod(new BcMath\Number('2.22'));
+var_dump($quot, $rem);
+
+echo PHP_EOL . '8.3 / 8.3' . PHP_EOL;
+[$quot, $rem] = new BcMath\Number('8.3')->divmod('8.3');
+var_dump($quot, $rem);
+
+echo PHP_EOL . '10 / -3' . PHP_EOL;
+[$quot, $rem] = new BcMath\Number('10')->divmod(-3);
+var_dump($quot, $rem);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+ BcMath\Number::divmod で scale を指定する例
+
+divmod(new BcMath\Number('2.22'), 1);
+var_dump($quot, $rem);
+
+echo PHP_EOL . '8.3 / 8.3' . PHP_EOL;
+[$quot, $rem] = new BcMath\Number('8.3')->divmod('8.3', 4);
+var_dump($quot, $rem);
+
+echo PHP_EOL . '10 / -3' . PHP_EOL;
+[$quot, $rem] = new BcMath\Number('10')->divmod(-3, 5);
+var_dump($quot, $rem);
+?>
+]]>
+
+ &example.outputs;
+
+
+ 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)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcdivmod
+ BcMath\Number::div
+ BcMath\Number::mod
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/floor.xml b/reference/bc/bcmath/number/floor.xml
new file mode 100644
index 0000000000..416e0f4824
--- /dev/null
+++ b/reference/bc/bcmath/number/floor.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+ BcMath\Number::floor
+ 任意精度数値を切り下げる
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::floor
+
+
+
+ 必要に応じて $this を切り下げ、 $this の次に小さい整数値を返します。
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::floor の例
+
+floor();
+$num2 = new BcMath\Number('9.999')->floor();
+$num3 = new BcMath\Number('-3.14')->floor();
+
+var_dump($num1, $num2, $num3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(1) "4"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(2) "-4"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcfloor
+ BcMath\Number::ceil
+ BcMath\Number::round
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/mod.xml b/reference/bc/bcmath/number/mod.xml
new file mode 100644
index 0000000000..c1efe07cf8
--- /dev/null
+++ b/reference/bc/bcmath/number/mod.xml
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+ BcMath\Number::mod
+ 任意精度数値の剰余を取得する
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::mod
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this を num で割った剰余を取得します。
+ num が 0 でない限り、 結果は $this
+ と同じ符号になります。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 剰余オブジェクトを新しい BcMath\Number オブジェクトとして返します。
+
+
+ 剰余オブジェクトの BcMath\Number::scale が自動的に設定される場合、剰余計算に使用する2つの数値のうち、
+ 大きい方の BcMath\Number::scale が使用されます。
+
+
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::mod で scale を指定しない例
+
+mod(new BcMath\Number('2.22'));
+$ret2 = $number->mod('8.3');
+$ret3 = $number->mod(-5);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "8.3"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(4) "1.64"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(3) "0.0"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "3.3"
+ ["scale"]=>
+ int(1)
+}
+]]>
+
+
+
+
+ BcMath\Number::mod で scale を指定する例
+
+mod(new BcMath\Number('2.22'), 1);
+$ret2 = $number->mod('8.3', 3);
+$ret3 = $number->mod(-5, 0);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "8.3"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(3) "1.6"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(5) "0.000"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(1) "3"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcmod
+ BcMath\Number::div
+ BcMath\Number::divmod
+ BcMath\Number::powmod
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/mul.xml b/reference/bc/bcmath/number/mul.xml
new file mode 100644
index 0000000000..3faa8e0a03
--- /dev/null
+++ b/reference/bc/bcmath/number/mul.xml
@@ -0,0 +1,184 @@
+
+
+
+
+
+
+ BcMath\Number::mul
+ 任意精度数値の乗算を行う
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::mul
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this に num を掛けます。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 乗数を表す値。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 乗算結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 乗算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、乗算に使用する2つの数値の
+ BcMath\Number::scale の合計値が使用されます。
+
+
+ つまり、2つの値の BcMath\Number::scale がそれぞれ 2 と 5 の場合、
+ 乗算結果オブジェクトの BcMath\Number::scale は 7 になります。
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::mul で scale を指定しない例
+
+mul(new BcMath\Number('2.3456'));
+$ret2 = $number->mul('-3.4');
+$ret3 = $number->mul(7);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(5) "1.234"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(9) "2.8944704"
+ ["scale"]=>
+ int(7)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(7) "-4.1956"
+ ["scale"]=>
+ int(4)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(5) "8.638"
+ ["scale"]=>
+ int(3)
+}
+]]>
+
+
+
+
+ BcMath\Number::mul で scale を指定する例
+
+mul(new BcMath\Number('2.3456'), 1);
+$ret2 = $number->mul('-3.4', 10);
+$ret3 = $number->mul(7, 0);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(5) "1.234"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(3) "2.8"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(13) "-4.1956000000"
+ ["scale"]=>
+ int(10)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(1) "8"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcmul
+ BcMath\Number::div
+ BcMath\Number::pow
+ BcMath\Number::powmod
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/pow.xml b/reference/bc/bcmath/number/pow.xml
new file mode 100644
index 0000000000..dbb6a72388
--- /dev/null
+++ b/reference/bc/bcmath/number/pow.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+ BcMath\Number::pow
+ 任意精度数値をべき乗する
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::pow
+ BcMath\Numberstringintexponent
+ intnullscale&null;
+
+
+ $this の
+ exponent 乗を求めます。
+
+
+
+
+ &reftitle.parameters;
+
+
+ exponent
+
+
+ 指数を表す値。整数値でなければなりません。
+ exponent の有効な範囲はプラットフォームに依存しますが、少なくとも
+ -2147483648 から 2147483647 までの範囲を持ちます。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ べき乗の結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ べき乗結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、
+ exponent の値に応じて、結果の BcMath\Number::scale が以下のようになります:
+
+
+
+
+ exponent
+ べき乗結果オブジェクトの BcMath\Number::scale
+
+
+
+
+ 正の値
+ (基数の BcMath\Number::scale) * (exponent の値)
+
+
+ 0
+ 0
+
+
+ 負の値
+ (基数の BcMath\Number::scale) と (基数の BcMath\Number::scale +
+ 10) の間
+
+
+
+
+
+
+ 負の exponent を指定し割り切れない除算が発生した場合、べき乗結果オブジェクトの
+ BcMath\Number::scale が拡張されます。拡張は必要な場合にのみ行われ、最大で +10 まで拡張されます。
+ この動作は BcMath\Number::div と同じですので、詳しくはそちらを参照して下さい。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、以下の場合に ValueError をスローします:
+
+ exponent が、BCMath で有効でない数値形式の文字列である場合
+ exponent が整数値でない場合
+ exponent もしくは scale が範囲外の値である場合
+ 結果オブジェクトの BcMath\Number::scale が範囲外の値である場合
+
+
+
+ このメソッドは、$this の値が 0 かつ exponent が負の値である場合、
+ DivisionByZeroError 例外をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::pow で scale を指定しない例
+
+pow(new BcMath\Number('5'));
+$ret2 = $number->pow('-1');
+$ret3 = $number->pow(0);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "3.0"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(9) "243.00000"
+ ["scale"]=>
+ int(5)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(13) "0.33333333333"
+ ["scale"]=>
+ int(11)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(1) "1"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+ BcMath\Number::pow で scale を指定する例
+
+pow(new BcMath\Number('5'), 0);
+$ret2 = $number->pow('-1', 2);
+$ret3 = $number->pow(0, 10);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "3.0"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(3) "243"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(4) "0.33"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(12) "1.0000000000"
+ ["scale"]=>
+ int(10)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcpow
+ BcMath\Number::powmod
+ BcMath\Number::mul
+ BcMath\Number::sqrt
+ BcMath\Number::div
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/powmod.xml b/reference/bc/bcmath/number/powmod.xml
new file mode 100644
index 0000000000..05344160fd
--- /dev/null
+++ b/reference/bc/bcmath/number/powmod.xml
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+ BcMath\Number::powmod
+ 任意精度数値のべき乗の、指定した数値による剰余
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::powmod
+ BcMath\Numberstringintexponent
+ BcMath\Numberstringintmodulus
+ intnullscale&null;
+
+
+ modulus で割った余りを求めることを考慮して、
+ $this の
+ exponent 乗を高速に計算します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ exponent
+
+
+ 基数を表す整数の値。
+ (つまり、scale は 0 でなければいけません)
+
+
+
+
+ modulus
+
+
+ 指数を表す、負でない、整数の値。
+ (つまり、scale は 0 でなければいけません)
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 計算結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 計算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、常に 0 になります。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、以下の場合に ValueError をスローします:
+
+ exponent もしくは modulus が、BCMath で有効でない数値形式の文字列である場合
+ $this か exponent か modulus のうち、どれか一つでも整数値でない場合
+ exponent が負の値である場合
+ scale が範囲外の値である場合
+
+
+
+ このメソッドは、 modulus が 0 である場合、
+ DivisionByZeroError 例外をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::powmod で scale を指定しない例
+
+powmod(new BcMath\Number('3'), 5),
+ new BcMath\Number('-8')->powmod(new BcMath\Number('3'), 5),
+ new BcMath\Number('8')->powmod('2', -3),
+ new BcMath\Number('-8')->powmod(5, 7),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(1) "2"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(2) "-2"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(1) "1"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(2) "-1"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+ BcMath\Number::powmod で scale を指定する例
+
+powmod(new BcMath\Number('3'), 5, 1),
+ new BcMath\Number('-8')->powmod(new BcMath\Number('3'), 5, 2),
+ new BcMath\Number('8')->powmod('2', -3, 3),
+ new BcMath\Number('-8')->powmod(5, 7, 4),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "2.0"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(5) "-2.00"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(5) "1.000"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(7) "-1.0000"
+ ["scale"]=>
+ int(4)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcpowmod
+ BcMath\Number::pow
+ BcMath\Number::mod
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/round.xml b/reference/bc/bcmath/number/round.xml
new file mode 100644
index 0000000000..9aed0bb0d3
--- /dev/null
+++ b/reference/bc/bcmath/number/round.xml
@@ -0,0 +1,568 @@
+
+
+
+
+
+
+ BcMath\Number::round
+ 任意精度数値を丸める
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::round
+ intprecision0
+ RoundingModemodeRoundingMode::HalfAwayFromZero
+
+
+ $this を、指定した precision(小数点以下の桁数)に丸めた値を返します。
+ precision を負またはゼロ(デフォルト) とすることも可能です。
+
+
+
+
+ &reftitle.parameters;
+
+
+
+
+ mode
+
+
+ 指定する丸めモード。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、無効な mode が指定された場合に ValueError をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::round の例
+
+round(),
+ new BcMath\Number('3.5')->round(),
+ new BcMath\Number('3.6')->round(),
+ new BcMath\Number('3.6')->round(0),
+ new BcMath\Number('5.045')->round(2),
+ new BcMath\Number('5.055')->round(2),
+ new BcMath\Number('345')->round(-2),
+ new BcMath\Number('345')->round(-3),
+ new BcMath\Number('678')->round(-2),
+ new BcMath\Number('678')->round(-3),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(1) "3"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(1) "4"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(1) "4"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(1) "4"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#6 (2) {
+ ["value"]=>
+ string(4) "5.05"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#7 (2) {
+ ["value"]=>
+ string(4) "5.06"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#8 (2) {
+ ["value"]=>
+ string(3) "300"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#9 (2) {
+ ["value"]=>
+ string(1) "0"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#10 (2) {
+ ["value"]=>
+ string(3) "700"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#11 (2) {
+ ["value"]=>
+ string(4) "1000"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+ BcMath\Number::round で異なる precision を指定した例
+
+
+round(3),
+ $number->round(2),
+ $number->round(1),
+ $number->round(0),
+ $number->round(-1),
+ $number->round(-2),
+ $number->round(-3),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(6) "123.45"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(6) "123.45"
+ ["scale"]=>
+ int(2)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(5) "123.5"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(3) "123"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#6 (2) {
+ ["value"]=>
+ string(3) "120"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#7 (2) {
+ ["value"]=>
+ string(3) "100"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#8 (2) {
+ ["value"]=>
+ string(1) "0"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+ BcMath\Number::round で異なる mode を指定した例
+
+
+round(0, RoundingMode::HalfAwayFromZero),
+ $number->round(0, RoundingMode::HalfTowardsZero),
+ $number->round(0, RoundingMode::HalfEven),
+ $number->round(0, RoundingMode::HalfOdd),
+ $number->round(0, RoundingMode::TowardsZero),
+ $number->round(0, RoundingMode::AwayFromZero),
+ $number->round(0, RoundingMode::NegativeInfinity),
+ $number->round(0, RoundingMode::PositiveInfinity),
+);
+
+echo PHP_EOL;
+echo 'Rounding modes with 8.5' . PHP_EOL;
+$number = new BcMath\Number('8.5');
+var_dump(
+ $number->round(0, RoundingMode::HalfAwayFromZero),
+ $number->round(0, RoundingMode::HalfTowardsZero),
+ $number->round(0, RoundingMode::HalfEven),
+ $number->round(0, RoundingMode::HalfOdd),
+ $number->round(0, RoundingMode::TowardsZero),
+ $number->round(0, RoundingMode::AwayFromZero),
+ $number->round(0, RoundingMode::NegativeInfinity),
+ $number->round(0, RoundingMode::PositiveInfinity),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(2) "10"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#7 (2) {
+ ["value"]=>
+ string(2) "10"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#9 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#11 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#13 (2) {
+ ["value"]=>
+ string(2) "10"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#15 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#17 (2) {
+ ["value"]=>
+ string(2) "10"
+ ["scale"]=>
+ int(0)
+}
+
+Rounding modes with 8.5
+object(BcMath\Number)#1 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#15 (2) {
+ ["value"]=>
+ string(1) "8"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#13 (2) {
+ ["value"]=>
+ string(1) "8"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#11 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#9 (2) {
+ ["value"]=>
+ string(1) "8"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#7 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(1) "8"
+ ["scale"]=>
+ int(0)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(1) "9"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+ BcMath\Number::round で precision を指定し、
+ 異なる mode を指定した例
+
+
+round(1, RoundingMode::HalfAwayFromZero),
+ $negative->round(1, RoundingMode::HalfAwayFromZero),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::HalfTowardsZero with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::HalfTowardsZero),
+ $negative->round(1, RoundingMode::HalfTowardsZero),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::HalfEven with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::HalfEven),
+ $negative->round(1, RoundingMode::HalfEven),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::HalfOdd with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::HalfOdd),
+ $negative->round(1, RoundingMode::HalfOdd),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::TowardsZero with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::TowardsZero),
+ $negative->round(1, RoundingMode::TowardsZero),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::AwayFromZero with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::AwayFromZero),
+ $negative->round(1, RoundingMode::AwayFromZero),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::NegativeInfinity with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::NegativeInfinity),
+ $negative->round(1, RoundingMode::NegativeInfinity),
+);
+
+echo PHP_EOL;
+echo 'Using RoundingMode::PositiveInfinity with 1 decimal digit precision' . PHP_EOL;
+var_dump(
+ $positive->round(1, RoundingMode::PositiveInfinity),
+ $negative->round(1, RoundingMode::PositiveInfinity),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(3) "1.6"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#5 (2) {
+ ["value"]=>
+ string(4) "-1.6"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::HalfTowardsZero with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.5"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#6 (2) {
+ ["value"]=>
+ string(4) "-1.5"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::HalfEven with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.6"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#7 (2) {
+ ["value"]=>
+ string(4) "-1.6"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::HalfOdd with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.5"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#8 (2) {
+ ["value"]=>
+ string(4) "-1.5"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::TowardsZero with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.5"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#9 (2) {
+ ["value"]=>
+ string(4) "-1.5"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::AwayFromZero with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.6"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#10 (2) {
+ ["value"]=>
+ string(4) "-1.6"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::NegativeInfinity with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.5"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#11 (2) {
+ ["value"]=>
+ string(4) "-1.6"
+ ["scale"]=>
+ int(1)
+}
+
+Using RoundingMode::PositiveInfinity with 1 decimal digit precision
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(3) "1.6"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#12 (2) {
+ ["value"]=>
+ string(4) "-1.5"
+ ["scale"]=>
+ int(1)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcround
+ BcMath\Number::ceil
+ BcMath\Number::floor
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/serialize.xml b/reference/bc/bcmath/number/serialize.xml
new file mode 100644
index 0000000000..2718261758
--- /dev/null
+++ b/reference/bc/bcmath/number/serialize.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+ BcMath\Number::__serialize
+ BcMath\Number オブジェクトをシリアライズする
+
+
+
+ &reftitle.description;
+
+ public arrayBcMath\Number::__serialize
+
+
+
+ $this をシリアライズします。
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::__construct
+ BcMath\Number::__unserialize
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/sqrt.xml b/reference/bc/bcmath/number/sqrt.xml
new file mode 100644
index 0000000000..c93f6995a2
--- /dev/null
+++ b/reference/bc/bcmath/number/sqrt.xml
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+ BcMath\Number::sqrt
+ 任意精度数値の平方根を取得する
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::sqrt
+ intnullscale&null;
+
+
+ $this の平方根を返します。
+
+
+
+
+ &reftitle.parameters;
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 平方根を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 計算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、$this の
+ BcMath\Number::scale が使用されます。ただし、割り切れない除算が発生した場合は、
+ 計算結果オブジェクトの BcMath\Number::scale が拡張されます。
+ 拡張は必要に応じてのみ行われ、最大で +10 まで拡張されます。
+ この動作は BcMath\Number::div と同じですので、詳しくはそちらを参照して下さい。
+
+
+ つまり、$this の BcMath\Number::scale が 5 の場合、
+ 計算結果オブジェクトの BcMath\Number::scale は 5 から
+ 15 の間になります。
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、以下の場合に ValueError をスローします:
+
+ $this が負の値である場合
+ scale が範囲外の値である場合
+ 結果オブジェクトの BcMath\Number::scale が範囲外の値である場合
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::sqrt の例
+
+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/bcmath/number/sub.xml b/reference/bc/bcmath/number/sub.xml
new file mode 100644
index 0000000000..e577386706
--- /dev/null
+++ b/reference/bc/bcmath/number/sub.xml
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+ BcMath\Number::sub
+ 任意精度数値の減算を行う
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::sub
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ $this と num を減算します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 減数を表す値。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 減算結果を新しい BcMath\Number オブジェクトとして返します。
+
+
+ 減算結果オブジェクトの BcMath\Number::scale が自動的に設定される場合、減算に使用する2つの数値のうち、
+ 大きい方の BcMath\Number::scale が使用されます。
+
+
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::sub で scale を指定しない例
+
+sub(new BcMath\Number('2.34567'));
+$ret2 = $number->sub('-3.456');
+$ret3 = $number->sub(7);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(5) "1.234"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(8) "-1.11167"
+ ["scale"]=>
+ int(5)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(5) "4.690"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(6) "-5.766"
+ ["scale"]=>
+ int(3)
+}
+]]>
+
+
+
+
+ BcMath\Number::sub で scale を指定する例
+
+sub(new BcMath\Number('2.34567'), 1);
+$ret2 = $number->sub('-3.456', 10);
+$ret3 = $number->sub(7, 0);
+
+var_dump($number, $ret1, $ret2, $ret3);
+?>
+]]>
+
+ &example.outputs;
+
+
+ string(5) "1.234"
+ ["scale"]=>
+ int(3)
+}
+object(BcMath\Number)#3 (2) {
+ ["value"]=>
+ string(4) "-1.1"
+ ["scale"]=>
+ int(1)
+}
+object(BcMath\Number)#2 (2) {
+ ["value"]=>
+ string(12) "4.6900000000"
+ ["scale"]=>
+ int(10)
+}
+object(BcMath\Number)#4 (2) {
+ ["value"]=>
+ string(2) "-5"
+ ["scale"]=>
+ int(0)
+}
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcsub
+ BcMath\Number::add
+
+
+
+
+
diff --git a/reference/bc/bcmath/number/tostring.xml b/reference/bc/bcmath/number/tostring.xml
new file mode 100644
index 0000000000..5a3aeb7d1b
--- /dev/null
+++ b/reference/bc/bcmath/number/tostring.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+ BcMath\Number::__toString
+ BcMath\Number オブジェクトを文字列に変換する
+
+
+
+ &reftitle.description;
+
+ public stringBcMath\Number::__toString
+
+
+
+ BcMath\Number を string に変換します。
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ BcMath\Number::value を string として返します。
+
+
+
+
diff --git a/reference/bc/bcmath/number/unserialize.xml b/reference/bc/bcmath/number/unserialize.xml
new file mode 100644
index 0000000000..42954cdbdc
--- /dev/null
+++ b/reference/bc/bcmath/number/unserialize.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+ BcMath\Number::__unserialize
+ data 引数を BcMath\Number オブジェクトとして復元する
+
+
+
+ &reftitle.description;
+
+ public voidBcMath\Number::__unserialize
+ arraydata
+
+
+ data 引数を BcMath\Number オブジェクトとして復元します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ data
+
+
+ 連想配列としてシリアライズされたデータ。
+
+
+
+
+
+
+
+ &reftitle.errors;
+
+ このメソッドは、不正なシリアライズデータが渡された場合、ValueError をスローします。
+
+
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::__construct
+ BcMath\Number::serialize
+
+
+
+
+
diff --git a/reference/bc/book.xml b/reference/bc/book.xml
index 86023d9966..c819a9aca4 100644
--- a/reference/bc/book.xml
+++ b/reference/bc/book.xml
@@ -1,6 +1,6 @@
-
+
@@ -55,6 +55,7 @@ echo bcsub($num1, $num2, 1); // => '0.0'
&reference.bc.setup;
&reference.bc.reference;
+ &reference.bc.bcmath.number;
diff --git a/reference/bc/functions/bcadd.xml b/reference/bc/functions/bcadd.xml
index 5fe0165cb8..cfb9dfa81f 100644
--- a/reference/bc/functions/bcadd.xml
+++ b/reference/bc/functions/bcadd.xml
@@ -1,6 +1,6 @@
-
+
@@ -42,7 +42,17 @@
- &bc.scale.description;
+
+ scale
+
+
+ 結果の小数点以下の桁数を指定します。&null; の場合は、 bcscale 関数でグローバルに
+ 設定した桁数をデフォルトとして使用します。
+ それも設定されていない場合は bcmath.scale
+ INI ディレクティブの値を使用します。
+
+
+
@@ -58,15 +68,10 @@
&reftitle.errors;
- This function throws a ValueError in the following cases:
+ この関数は、以下の場合に ValueError をスローします:
-
- num1 or num2
- is not a well-formed BCMath numeric string.
-
-
- scale is outside the valid range.
-
+ num1 もしくは num1 が、BCMath で有効でない数値形式の文字列である場合
+ scale が範囲外の値である場合
@@ -118,6 +123,7 @@ echo bcadd($a, $b, 4); // 6.2340
bcsub
+ BcMath\Number::add
diff --git a/reference/bc/functions/bcceil.xml b/reference/bc/functions/bcceil.xml
new file mode 100644
index 0000000000..130742f983
--- /dev/null
+++ b/reference/bc/functions/bcceil.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+ bcceil
+ 任意精度数値を切り上げる
+
+
+
+ &reftitle.description;
+
+ stringbcceil
+ stringnum
+
+
+ 必要に応じて num を切り上げ、 num の次に大きい整数値を返します。
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ 切り上げる値を表す文字列。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ num に最も近い整数に切り上げられた数値を表す数値文字列を返します。
+
+
+
+
+ &reftitle.errors;
+
+ この関数は、num が BCMath で有効でない数値形式の文字列である場合、ValueError をスローします。
+
+
+
+
+ &reftitle.examples;
+
+ bcceil の例
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcfloor
+ bcround
+ BcMath\Number::ceil
+
+
+
+
diff --git a/reference/bc/functions/bccomp.xml b/reference/bc/functions/bccomp.xml
index 5bf0bf6e72..c93016b4df 100644
--- a/reference/bc/functions/bccomp.xml
+++ b/reference/bc/functions/bccomp.xml
@@ -1,6 +1,6 @@
-
+
@@ -77,6 +77,13 @@ echo bccomp('1.00001', '1', 5); // 1
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::compare
+
+
-
+
@@ -42,7 +42,7 @@
- &bc.scale.description;
+
@@ -60,8 +60,8 @@
- This function throws a DivisionByZeroError
- exception if num2 is 0.
+ この関数は、 num2 が 0 である場合、
+ DivisionByZeroError 例外をスローします。
@@ -108,6 +108,7 @@ echo bcdiv('105', '6.55957', 3); // 16.007
bcmul
+ BcMath\Number::div
diff --git a/reference/bc/functions/bcdivmod.xml b/reference/bc/functions/bcdivmod.xml
new file mode 100644
index 0000000000..a66e1abbe5
--- /dev/null
+++ b/reference/bc/functions/bcdivmod.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+ bcdivmod
+ 任意精度数値の商と剰余を取得する
+
+
+
+ &reftitle.description;
+
+ arraybcdivmod
+ stringnum1
+ stringnum2
+ intnullscale&null;
+
+
+ num1 を num2 で割った商と剰余を取得します。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ 1つ目の要素に商の値を表す string が、2つ目の要素に剰余の値を表す string が格納された配列を返します。
+
+
+
+
+
+
+ &reftitle.examples;
+
+ bcdivmod の例
+
+
+]]>
+
+
+
+ bcdivmod に小数の値を指定する
+
+
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcdiv
+ bcmod
+ BcMath\Number::divmod
+
+
+
+
diff --git a/reference/bc/functions/bcfloor.xml b/reference/bc/functions/bcfloor.xml
new file mode 100644
index 0000000000..912eec25c0
--- /dev/null
+++ b/reference/bc/functions/bcfloor.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+ bcfloor
+ 任意精度数値を切り下げる
+
+
+
+ &reftitle.description;
+
+ stringbcfloor
+ stringnum
+
+
+ 必要に応じて num を切り下げ、 num の次に小さい整数値を返します。
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ num に最も近い整数に切り下げられた数値を表す数値文字列を返します。
+
+
+
+
+
+
+ &reftitle.examples;
+
+ bcfloor の例
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcceil
+ bcround
+ BcMath\Number::floor
+
+
+
+
diff --git a/reference/bc/functions/bcmod.xml b/reference/bc/functions/bcmod.xml
index cee36b6cb4..da59ddd1bb 100644
--- a/reference/bc/functions/bcmod.xml
+++ b/reference/bc/functions/bcmod.xml
@@ -1,6 +1,6 @@
-
+
@@ -57,7 +57,8 @@
8.0.0
- Dividing by 0 now throws a DivisionByZeroError exception instead of returning null.
+ 0 除算を行うと、DivisionByZeroError
+ 例外がスローされるようになりました。以前は &null; が返されていました。
@@ -115,6 +116,7 @@ echo bcmod('5.7', '1.3'); // 0.5 as of PHP 7.2.0; 0 previously
bcdiv
+ BcMath\Number::mod
diff --git a/reference/bc/functions/bcmul.xml b/reference/bc/functions/bcmul.xml
index d07a12fba4..a38c3364f2 100644
--- a/reference/bc/functions/bcmul.xml
+++ b/reference/bc/functions/bcmul.xml
@@ -1,6 +1,6 @@
-
+
@@ -108,6 +108,7 @@ echo bcmul('5', '2', 2); // prints "10", not "10.00"
bcdiv
+ BcMath\Number::mul
diff --git a/reference/bc/functions/bcpow.xml b/reference/bc/functions/bcpow.xml
index 81bbe8b1ca..fee6a8e2fa 100644
--- a/reference/bc/functions/bcpow.xml
+++ b/reference/bc/functions/bcpow.xml
@@ -1,8 +1,8 @@
-
+
-
+
bcpow
任意精度数値をべき乗する
@@ -46,7 +46,7 @@
- &bc.scale.description;
+
@@ -61,16 +61,16 @@
&reftitle.errors;
- This function throws a ValueError in the following cases:
+ この関数は、以下の場合に ValueError をスローします:
- num or exponent is not a well-formed BCMath numeric string
- exponent has a fractional part
- exponent or scale is outside the valid range
+ num もしくは exponent が、BCMath で有効でない数値形式の文字列である場合
+ exponent が整数値でない場合
+ exponent もしくは scale が範囲外の値である場合
- This function throws a DivisionByZeroError exception if num
- is 0 and exponent is a negative value.
+ この関数は、num の値が 0 かつ exponent が負の値である場合、
+ DivisionByZeroError 例外をスローします。
@@ -88,15 +88,16 @@
8.4.0
- Negative powers of 0 previously returned 0, but now throw a DivisionByZeroError
- exception.
+ 0 の負のべき乗を行った場合、0 を返す代わりに
+ DivisionByZeroError がスローされるようになりました。
8.0.0
- When exponent has a fractional part, it now throws a ValueError
- instead of truncating.
+ exponent が小数部を持つ場合、ValueError
+ がスローされるようになりました。
+ 以前は、小数部を切り捨てて整数として計算を行っていました。
@@ -156,6 +157,7 @@ echo bcpow('5', '2', 2); // 結果は "25.00" ではなく "25" となりま
bcpowmod
bcsqrt
+ BcMath\Number::pow
diff --git a/reference/bc/functions/bcpowmod.xml b/reference/bc/functions/bcpowmod.xml
index 0f289e1121..6f59e0eae5 100644
--- a/reference/bc/functions/bcpowmod.xml
+++ b/reference/bc/functions/bcpowmod.xml
@@ -1,8 +1,8 @@
-
+
-
+
bcpowmod
任意精度数値のべき乗の、指定した数値による剰余
@@ -55,7 +55,7 @@
- &bc.scale.description;
+
@@ -70,17 +70,17 @@
&reftitle.errors;
- This function throws a ValueError in the following cases:
+ この関数は、以下の場合に ValueError をスローします:
- num, exponent or modulus is not a well-formed BCMath numeric string
- num, exponent or modulus has a fractional part
- exponent is a negative value
- scale is outside the valid range
+ num か exponent か modulus のいずれかが、BCMath で有効でない数値形式の文字列である場合
+ num か exponent か modulus のいずれかが整数値でない場合
+ exponent が負の値である場合
+ scale が範囲外の値である場合
- This function throws a DivisionByZeroError exception if modulus
- is 0.
+ この関数は、modulus の値が 0 である場合、
+ DivisionByZeroError 例外をスローします。
@@ -104,13 +104,14 @@
8.0.0
- Now throws a ValueError instead of returning &false; if exponent is a negative value.
+ exponent が負の値の場合、&false; を返す代わりに ValueError をスローするようになりました。
8.0.0
- Dividing by 0 now throws a DivisionByZeroError exception instead of returning &false;.
+ 0 除算を行うと、DivisionByZeroError
+ 例外がスローされるようになりました。以前は &false; が返されていました。
@@ -157,6 +158,7 @@ $b = bcmod(bcpow($x, $y), $mod);
bcpow
bcmod
+ BcMath\Number::powmod
diff --git a/reference/bc/functions/bcround.xml b/reference/bc/functions/bcround.xml
new file mode 100644
index 0000000000..d9b90f87be
--- /dev/null
+++ b/reference/bc/functions/bcround.xml
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+ bcround
+ 任意精度数値を丸める
+
+
+
+ &reftitle.description;
+
+ stringbcround
+ stringnum
+ intprecision0
+ RoundingModemodeRoundingMode::HalfAwayFromZero
+
+
+ num を、指定した precision(小数点以下の桁数)に丸めた値を返します。
+ precision を負またはゼロ(デフォルト) とすることも可能です。
+
+
+
+
+ &reftitle.parameters;
+
+
+
+
+ mode
+
+
+ 指定する丸めモード。
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ num を指定された精度へ丸めた数値を表す文字列を返します。
+
+
+
+
+ &reftitle.errors;
+
+ この関数は、以下の場合に ValueError をスローします:
+
+ num が、BCMath で有効でない数値形式の文字列である場合
+ 無効な mode を指定した場合
+
+
+
+
+
+ &reftitle.examples;
+
+ bcround の例
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+ bcround で異なる precision を指定した例
+
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+ bcround で異なる mode を指定した例
+
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+ bcround で precision を指定し、
+ 異なる mode を指定した例
+
+
+
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+
+ &reftitle.seealso;
+
+ bcceil
+ bcfloor
+ BcMath\Number::round
+
+
+
+
diff --git a/reference/bc/functions/bcscale.xml b/reference/bc/functions/bcscale.xml
index dcb6ce5e6b..fa4dda6c2a 100644
--- a/reference/bc/functions/bcscale.xml
+++ b/reference/bc/functions/bcscale.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/reference/bc/functions/bcsqrt.xml b/reference/bc/functions/bcsqrt.xml
index c131abf7eb..48fe2b452e 100644
--- a/reference/bc/functions/bcsqrt.xml
+++ b/reference/bc/functions/bcsqrt.xml
@@ -1,8 +1,8 @@
-
+
-
+
bcsqrt
任意精度数値の平方根を取得する
@@ -32,7 +32,7 @@
- &bc.scale.description;
+
@@ -116,6 +116,7 @@ echo bcsqrt('2', 3); // 1.414
bcpow
+ BcMath\Number::sqrt
diff --git a/reference/bc/functions/bcsub.xml b/reference/bc/functions/bcsub.xml
index 1f0cf6061e..f8aa2029f6 100644
--- a/reference/bc/functions/bcsub.xml
+++ b/reference/bc/functions/bcsub.xml
@@ -1,6 +1,6 @@
-
+
@@ -48,7 +48,7 @@
8.0.0
- scale is now nullable.
+ scale は nullable になりました。
@@ -81,6 +81,7 @@ echo bcsub($a, $b, 4); // -3.7660
bcadd
+ BcMath\Number::sub
diff --git a/reference/bc/ini.xml b/reference/bc/ini.xml
index 78484462ab..afd5470a45 100644
--- a/reference/bc/ini.xml
+++ b/reference/bc/ini.xml
@@ -1,6 +1,6 @@
-
+
&reftitle.runtime;
@@ -44,6 +44,9 @@
全ての bcmath 関数に関する 10 進桁数。
bcscale も参照ください。
+
+ BcMath\Number クラスは、この設定の影響を受けません。
+
diff --git a/translation.xml b/translation.xml
index bcda3c1d3d..30983a198a 100644
--- a/translation.xml
+++ b/translation.xml
@@ -31,6 +31,7 @@
+