diff --git a/reference/bc/bcmath.number.xml b/reference/bc/bcmath.number.xml
new file mode 100644
index 000000000000..205df12422ca
--- /dev/null
+++ b/reference/bc/bcmath.number.xml
@@ -0,0 +1,119 @@
+
+
+
+
+ The BcMath\Number class
+ BcMath\Number
+
+
+
+ &reftitle.intro;
+
+ A class for an arbitrary precision number.
+ These objects support overloaded
+ arithmetic and
+ comparison operators.
+
+
+
+
+ This class is not affected by the
+ bcmath.scale
+ INI directive set in &php.ini;.
+
+
+
+
+
+ The behavior of an overloaded operator is the same as specifying &null; for the
+ scale parameter on the corresponding method.
+
+
+
+
+
+ &reftitle.classsynopsis;
+
+
+
+ final
+ readonly
+ BcMath\Number
+
+
+
+ implements
+ Stringable
+
+
+ &Properties;
+
+ public
+ string
+ value
+
+
+ public
+ int
+ scale
+
+
+ &Methods;
+
+
+
+
+
+
+
+
+
+
+ &reftitle.properties;
+
+
+ value
+
+
+ A string representation of an arbitrary precision number.
+
+
+
+
+ scale
+
+
+ The scale value currently set on the object.
+ For objects resulting from calculations, this value is automatically computed and set,
+ unless the scale parameter was set in the calculation method.
+
+
+
+
+
+
+
+
+ &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 000000000000..7bdfaff6aae1
--- /dev/null
+++ b/reference/bc/bcmath/number/add.xml
@@ -0,0 +1,193 @@
+
+
+
+ BcMath\Number::add
+ Adds an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::add
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Adds $this and num.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ The value to add.
+
+
+
+
+ scale
+
+
+ scale explicitly specified for calculation results.
+ If &null;, the scale of the calculation result will be set automatically.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result of addition as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the greater BcMath\Number::scale of the two numbers used for addition is used.
+
+
+ That is, if the BcMath\Number::scales of two values are 2
+ and 5 respectively, the BcMath\Number::scale of the result
+ will be 5.
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError in the following cases:
+
+ num is string and not a well-formed BCMath numeric string
+ scale is outside the valid range
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::add example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..8225b87d7c92
--- /dev/null
+++ b/reference/bc/bcmath/number/ceil.xml
@@ -0,0 +1,103 @@
+
+
+
+ BcMath\Number::ceil
+ Rounds up an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::ceil
+
+
+
+ Returns the next highest integer value by rounding up
+ $this if necessary.
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result as a new BcMath\Number object.
+ The BcMath\Number::scale of the result is always 0.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::ceil example
+
+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 000000000000..22d2d40104f5
--- /dev/null
+++ b/reference/bc/bcmath/number/compare.xml
@@ -0,0 +1,140 @@
+
+
+
+ BcMath\Number::compare
+ Compares two arbitrary precision numbers
+
+
+
+ &reftitle.description;
+
+ public intBcMath\Number::compare
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Compare two arbitrary precision numbers.
+ This method behaves similar to the spaceship operator.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ The value to be compared to.
+
+
+
+
+ scale
+
+
+ Specify the scale to use for comparison.
+ If &null;, all digits are used in the comparison.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns 0 if the two numbers are equal,
+ 1 if $this is greater than num,
+ -1 otherwise.
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::compare example when scale is not specified
+
+compare(new BcMath\Number('1.234')),
+ $number->compare('1.23400'),
+ $number->compare('1.23401'),
+ $number->compare(1),
+);
+?>
+]]>
+
+ &example.outputs;
+
+
+
+
+
+
+ BcMath\Number::compare example of explicitly specifying 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 000000000000..cbf2744a3377
--- /dev/null
+++ b/reference/bc/bcmath/number/construct.xml
@@ -0,0 +1,114 @@
+
+
+
+ BcMath\Number::__construct
+ Creates a BcMath\Number object
+
+
+
+ &reftitle.description;
+
+ public BcMath\Number::__construct
+ stringintnum
+
+
+ Creates a BcMath\Number object from an int or string value.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ An int or string value.
+ If num is a int,
+ the BcMath\Number::scale is always set to 0.
+ If num is a string, it must be a valid number,
+ and the BcMath\Number::scale is automatically set by parsing the string.
+
+
+
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError if num
+ is string and not a well-formed BCMath numeric string.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::__construct example
+
+
+]]>
+
+ &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 000000000000..26432822a848
--- /dev/null
+++ b/reference/bc/bcmath/number/div.xml
@@ -0,0 +1,243 @@
+
+
+
+ BcMath\Number::div
+ Divides by an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::div
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Divides $this by num.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ The divisor.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result of division as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the BcMath\Number::scale of the dividend is used. However, in cases such
+ as indivisible division, the BcMath\Number::scale of the result is expanded.
+ Expansion is done only as needed, up to a maximum of +10.
+
+
+ That is, if the BcMath\Number::scale of the dividend is 5,
+ the BcMath\Number::scale of the result is between 5 and
+ 15.
+
+
+ Even in indivisible calculations, the BcMath\Number::scale will not always be
+ +10.
+ A 0 at the end of the result is considered not to need expansion, so the
+ BcMath\Number::scale is reduced by that amount.
+ The BcMath\Number::scale will never be less than the
+ BcMath\Number::scale before expansion.
+ See also the code example.
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError in the following cases:
+
+ num is string and not a well-formed BCMath numeric string
+ scale is outside the valid range
+ BcMath\Number::scale of the result object is outside the valid range
+
+
+
+ This method throws a DivisionByZeroError exception if
+ num is 0.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::div example when scale is not specified
+
+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 example of explicitly specifying 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 example of expansioning BcMath\Number::scale of result object
+
+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 000000000000..6a9764a7c32f
--- /dev/null
+++ b/reference/bc/bcmath/number/divmod.xml
@@ -0,0 +1,221 @@
+
+
+
+ BcMath\Number::divmod
+ Gets the quotient and modulus of an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public arrayBcMath\Number::divmod
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Gets the quotient and remainder of dividing $this by num.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns an indexed array where the first element is the quotient as a new
+ BcMath\Number object and the second element is the remainder as a new
+ BcMath\Number object.
+
+
+ The quotient is always an integer value, so BcMath\Number::scale of the quotient will
+ always be 0, regardless of whether explicitly specify scale.
+
+
+ If scale is explicitly specified, BcMath\Number::scale of the
+ remainder will be the specified value.
+ When the BcMath\Number::scale of the result's remainder object is automatically set,
+ the greater BcMath\Number::scale of the two numbers used for modulus operation is used.
+
+
+ That is, if the BcMath\Number::scales of two values are 2
+ and 5 respectively, the BcMath\Number::scale of the remainder
+ will be 5.
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::divmod example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..73019805c6c8
--- /dev/null
+++ b/reference/bc/bcmath/number/floor.xml
@@ -0,0 +1,98 @@
+
+
+
+ BcMath\Number::floor
+ Rounds down an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::floor
+
+
+
+ Returns the next highest integer value by rounding down
+ $this if necessary.
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::floor example
+
+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 000000000000..d092af26f27c
--- /dev/null
+++ b/reference/bc/bcmath/number/mod.xml
@@ -0,0 +1,171 @@
+
+
+
+ BcMath\Number::mod
+ Gets the modulus of an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::mod
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Gets the remainder of dividing $this by num.
+ Unless num is 0, the result has the same sign
+ as $this.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the modulus as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the greater BcMath\Number::scale of the two numbers used for modulus operation is used.
+
+
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::mod example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..aa3d55370fa6
--- /dev/null
+++ b/reference/bc/bcmath/number/mul.xml
@@ -0,0 +1,182 @@
+
+
+
+ BcMath\Number::mul
+ Multiplies an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::mul
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Multiplies $this by num.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ The multiplier.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result of multiplication as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the sum of the BcMath\Number::scales of the two values used for multiplication is used.
+
+
+ That is, if the BcMath\Number::scales of two values are 2
+ and 5 respectively, the BcMath\Number::scale of the result
+ will be 7.
+
+
+
+
+ &reftitle.errors;
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::mul example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..84eff1ff4fa9
--- /dev/null
+++ b/reference/bc/bcmath/number/pow.xml
@@ -0,0 +1,223 @@
+
+
+
+ BcMath\Number::pow
+ Raises an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::pow
+ BcMath\Numberstringintexponent
+ intnullscale&null;
+
+
+ Raises $this to the exponent power.
+
+
+
+
+ &reftitle.parameters;
+
+
+ exponent
+
+
+ The exponent. Must be a value with no fractional part.
+ The valid range of the exponent is platform specific,
+ but it is at least -2147483648 to 2147483647.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result of power as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ depending on the value of exponent, the BcMath\Number::scale
+ of result will be as follows:
+
+
+
+
+ exponent
+ BcMath\Number::scale of result
+
+
+
+
+ positive
+ (BcMath\Number::scale of power base) * (exponent's value)
+
+
+ 0
+ 0
+
+
+ negative
+ Between (BcMath\Number::scale of power base) and (BcMath\Number::scale
+ of power base + 10)
+
+
+
+
+
+
+ If an indivisible division occurs due to a negative exponent, the
+ BcMath\Number::scale of the result is expanded. Expansion is done only as needed, up to
+ a maximum of +10.
+ This behavior is the same as BcMath\Number::div, so please see that for details.
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError in the following cases:
+
+ exponent is string and not a well-formed BCMath numeric string
+ exponent has a fractional part
+ exponent or scale is outside the valid range
+ BcMath\Number::scale of the result object is outside the valid range
+
+
+
+ This method throws a DivisionByZeroError exception if $this's value
+ is 0 and exponent is a negative value.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::pow example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..fdc4cd1cf841
--- /dev/null
+++ b/reference/bc/bcmath/number/powmod.xml
@@ -0,0 +1,196 @@
+
+
+
+ BcMath\Number::powmod
+ Raises an arbitrary precision number, reduced by a specified modulus
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::powmod
+ BcMath\Numberstringintexponent
+ BcMath\Numberstringintmodulus
+ intnullscale&null;
+
+
+ Use the fast-exponentiation method to raise $this to the power
+ exponent with respect to the modulus modulus.
+
+
+
+
+ &reftitle.parameters;
+
+
+ exponent
+
+
+ The exponent, as an non-negative and integral (i.e. the scale has to be zero).
+
+
+
+
+ modulus
+
+
+ The modulus, as an integral (i.e. the scale has to be zero).
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the BcMath\Number::scale of the result object will always be 0.
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError in the following cases:
+
+ exponent or modulus is string and not
+ a well-formed BCMath numeric string
+ $this, exponent or modulus has a fractional part
+ exponent is a negative value
+ scale is outside the valid range
+
+
+
+ This method throws a DivisionByZeroError exception if modulus
+ is 0.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::powmod example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..d1669e97d2d4
--- /dev/null
+++ b/reference/bc/bcmath/number/round.xml
@@ -0,0 +1,560 @@
+
+
+
+ BcMath\Number::round
+ Rounds an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::round
+ intprecision0
+ RoundingModemodeRoundingMode::HalfAwayFromZero
+
+
+ Returns the rounded value of $this to
+ specified precision
+ (number of digits after the decimal point).
+ precision can also be negative or zero (default).
+
+
+
+
+ &reftitle.parameters;
+
+
+
+
+ mode
+
+
+ Specifies the rounding mode.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result as a new BcMath\Number object.
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::round example
+
+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)
+}
+]]>
+
+
+
+
+ Example of using BcMath\Number::round with different precision values
+
+
+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)
+}
+]]>
+
+
+
+
+ Example of using BcMath\Number::round with different mode values
+
+
+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)
+}
+]]>
+
+
+
+
+ Example of using BcMath\Number::round with different mode values
+ when specifying precision
+
+
+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 000000000000..144aa329ed48
--- /dev/null
+++ b/reference/bc/bcmath/number/serialize.xml
@@ -0,0 +1,52 @@
+
+
+
+ BcMath\Number::__serialize
+ Serializes a BcMath\Number object
+
+
+
+ &reftitle.description;
+
+ public arrayBcMath\Number::__serialize
+
+
+
+ Serializes $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 000000000000..be99915ff390
--- /dev/null
+++ b/reference/bc/bcmath/number/sqrt.xml
@@ -0,0 +1,133 @@
+
+
+
+ BcMath\Number::sqrt
+ Gets the square root of an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::sqrt
+ intnullscale&null;
+
+
+ Return the square root of $this.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the square root as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the BcMath\Number::scale of this object is used. However, in cases such
+ as indivisible division, the BcMath\Number::scale of the result is expanded.
+ Expansion is done only as needed, up to a maximum of +10.
+
+
+ That is, if the BcMath\Number::scale of this object is 5,
+ the BcMath\Number::scale of the result is between 5 and
+ 15.
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError in the following cases:
+
+ This object is a negative value
+ scale is outside the valid range
+ BcMath\Number::scale of the result object is outside the valid range
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::sqrt example
+
+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 000000000000..2d037b11ff60
--- /dev/null
+++ b/reference/bc/bcmath/number/sub.xml
@@ -0,0 +1,174 @@
+
+
+
+ BcMath\Number::sub
+ Subtracts an arbitrary precision number
+
+
+
+ &reftitle.description;
+
+ public BcMath\NumberBcMath\Number::sub
+ BcMath\Numberstringintnum
+ intnullscale&null;
+
+
+ Subtracts num from $this.
+
+
+
+
+ &reftitle.parameters;
+
+
+ num
+
+
+ The value to subtract.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ Returns the result of subtraction as a new BcMath\Number object.
+
+
+ When the BcMath\Number::scale of the result object is automatically set,
+ the greater BcMath\Number::scale of the two numbers used for subtraction is used.
+
+
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ BcMath\Number::sub example when scale is not specified
+
+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 example of explicitly specifying 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 000000000000..6059b5b8400a
--- /dev/null
+++ b/reference/bc/bcmath/number/tostring.xml
@@ -0,0 +1,50 @@
+
+
+
+ BcMath\Number::__toString
+ Converts BcMath\Number to string
+
+
+
+ &reftitle.description;
+
+ public stringBcMath\Number::__toString
+
+
+
+ Converts BcMath\Number to string.
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ Returns BcMath\Number::value as a string.
+
+
+
+
diff --git a/reference/bc/bcmath/number/unserialize.xml b/reference/bc/bcmath/number/unserialize.xml
new file mode 100644
index 000000000000..33504505bae2
--- /dev/null
+++ b/reference/bc/bcmath/number/unserialize.xml
@@ -0,0 +1,68 @@
+
+
+
+ BcMath\Number::__unserialize
+ Deserializes a data parameter into a BcMath\Number object
+
+
+
+ &reftitle.description;
+
+ public voidBcMath\Number::__unserialize
+ arraydata
+
+
+ Deserializes a data parameter into a BcMath\Number object.
+
+
+
+
+ &reftitle.parameters;
+
+
+ data
+
+
+ The serialized data parameter as an associative array
+
+
+
+
+
+
+
+ &reftitle.errors;
+
+ This method throws a ValueError if invalid serialized data is passed.
+
+
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::__construct
+ BcMath\Number::serialize
+
+
+
+
+
diff --git a/reference/bc/book.xml b/reference/bc/book.xml
index 6ccda4651a1c..a59db0da29e8 100644
--- a/reference/bc/book.xml
+++ b/reference/bc/book.xml
@@ -48,6 +48,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 bf94baeb4630..481853f307f5 100644
--- a/reference/bc/functions/bcadd.xml
+++ b/reference/bc/functions/bcadd.xml
@@ -99,6 +99,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
index d2e9be85e986..612f1d29bad0 100644
--- a/reference/bc/functions/bcceil.xml
+++ b/reference/bc/functions/bcceil.xml
@@ -68,6 +68,7 @@ string(2) "-3"
bcfloor
bcround
+ BcMath\Number::ceil
diff --git a/reference/bc/functions/bccomp.xml b/reference/bc/functions/bccomp.xml
index 052c5d4f6718..bc91a27be654 100644
--- a/reference/bc/functions/bccomp.xml
+++ b/reference/bc/functions/bccomp.xml
@@ -103,6 +103,13 @@ echo bccomp('1.00001', '1', 5); // 1
+
+
+ &reftitle.seealso;
+
+ BcMath\Number::compare
+
+