Skip to content

Commit 22792d5

Browse files
committed
Address comments and more
1 parent 3ffc207 commit 22792d5

File tree

16 files changed

+116
-873
lines changed

16 files changed

+116
-873
lines changed

reference/bc/bcmath.number.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
<note>
1919
<simpara>
20-
This class is not affected by <parameter>bcmath.scale</parameter> in &php.ini;.
20+
This class is not affected by <link linkend="ini.bcmath.scale">bcmath.scale</link>
21+
in &php.ini;.
2122
</simpara>
2223
</note>
2324

2425
<note>
2526
<simpara>
26-
The behavior of an overloaded operator is that of the corresponding method.
27+
The behavior of an overloaded operator is the same as specifying &null; for the
28+
<parameter>scale</parameter> parameter in the corresponding method.
2729
</simpara>
2830
</note>
2931
</section>
@@ -81,6 +83,8 @@
8183
<listitem>
8284
<simpara>
8385
The scale value currently set on the object.
86+
For objects resulting from calculations, this value is set automatically unless explicitly
87+
specify the <parameter>scale</parameter> parameter in the calculation method.
8488
</simpara>
8589
</listitem>
8690
</varlistentry>

reference/bc/bcmath/number/add.xml

Lines changed: 8 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>scale</parameter><initializer>&null;</initializer></methodparam>
1414
</methodsynopsis>
1515
<simpara>
16-
Adds this object and <parameter>num</parameter>.
16+
Adds <varname>$this</varname> and <parameter>num</parameter>.
1717
</simpara>
1818
</refsect1>
1919

@@ -38,7 +38,13 @@
3838
Returns the result of addition as a new <classname>BcMath\Number</classname> object.
3939
</simpara>
4040
<simpara>
41-
The same is true for calculations using operators that correspond to this method.
41+
When the <property>BcMath\Number::scale</property> of the result object is automatically set,
42+
the larger <property>BcMath\Number::scale</property> of the two numbers used for addition is used.
43+
</simpara>
44+
<simpara>
45+
That is, if the <property>BcMath\Number::scale</property>s of two values are <literal>2</literal>
46+
and <literal>5</literal> respectively, the <property>BcMath\Number::scale</property> of the result
47+
will be <literal>5</literal>.
4248
</simpara>
4349
</refsect1>
4450

@@ -51,28 +57,6 @@
5157
<member><parameter>scale</parameter> is outside the valid range</member>
5258
</simplelist>
5359
</para>
54-
<simpara>
55-
When using the operator, throw a <exceptionname>ValueError</exceptionname> if one of the operands
56-
is <type>string</type> and not a well-formed BCMath numeric string.
57-
</simpara>
58-
</refsect1>
59-
60-
<refsect1 role="bc.autoscale">
61-
<title>Auto scale</title>
62-
<simpara>
63-
When the <property>BcMath\Number::scale</property> of the result object is automatically set,
64-
the larger <property>BcMath\Number::scale</property> of the two numbers used for addition is used.
65-
</simpara>
66-
<simpara>
67-
That is, if the <property>BcMath\Number::scale</property>s of two values are <literal>2</literal>
68-
and <literal>5</literal> respectively, the <property>BcMath\Number::scale</property> of the result
69-
will be <literal>5</literal>.
70-
</simpara>
71-
<simpara>
72-
If either of the two values is a <type>string</type>, the <property>BcMath\Number::scale</property>
73-
of the <type>string</type> value is automatically obtained. For <type>int</type>, <parameter>scale
74-
</parameter> is treated as <literal>0</literal>.
75-
</simpara>
7660
</refsect1>
7761

7862
<refsect1 role="examples">
@@ -170,100 +154,6 @@ object(BcMath\Number)#4 (2) {
170154
</example>
171155
</refsect1>
172156

173-
<refsect1 role="bc.operatoroverload">
174-
<title>Operator Overload</title>
175-
<simpara>
176-
<classname>BcMath\Number</classname> can perform addition using operators. The calculation with
177-
the operator behaves the same as when the method argument <parameter>scale</parameter> is &null;.
178-
</simpara>
179-
<example>
180-
<title>Example of addition using operators</title>
181-
<programlisting role="php">
182-
<![CDATA[
183-
<?php
184-
$number = new BcMath\Number('1.234');
185-
186-
$ret1 = $number + new BcMath\Number('2.34567');
187-
$ret2 = $number + '-3.45678';
188-
$ret3 = $number + 7;
189-
190-
var_dump($number, $ret1, $ret2, $ret3);
191-
?>
192-
]]>
193-
</programlisting>
194-
&example.outputs;
195-
<screen>
196-
<![CDATA[
197-
object(BcMath\Number)#1 (2) {
198-
["value"]=>
199-
string(5) "1.234"
200-
["scale"]=>
201-
int(3)
202-
}
203-
object(BcMath\Number)#3 (2) {
204-
["value"]=>
205-
string(7) "3.57967"
206-
["scale"]=>
207-
int(5)
208-
}
209-
object(BcMath\Number)#2 (2) {
210-
["value"]=>
211-
string(8) "-2.22278"
212-
["scale"]=>
213-
int(5)
214-
}
215-
object(BcMath\Number)#4 (2) {
216-
["value"]=>
217-
string(5) "8.234"
218-
["scale"]=>
219-
int(3)
220-
}
221-
]]>
222-
</screen>
223-
</example>
224-
225-
<example>
226-
<title>Examples of increment and shorthand addition using operators</title>
227-
<programlisting role="php">
228-
<![CDATA[
229-
<?php
230-
$number = new BcMath\Number('1.234');
231-
$num1 = $number;
232-
$num2 = $number;
233-
234-
$num1 += new BcMath\Number('2.345');
235-
$num2++;
236-
237-
var_dump($number, $num1, $num2);
238-
?>
239-
]]>
240-
</programlisting>
241-
&example.outputs;
242-
<screen>
243-
<![CDATA[
244-
object(BcMath\Number)#1 (2) {
245-
["value"]=>
246-
string(5) "1.234"
247-
["scale"]=>
248-
int(3)
249-
}
250-
object(BcMath\Number)#3 (2) {
251-
["value"]=>
252-
string(5) "3.579"
253-
["scale"]=>
254-
int(3)
255-
}
256-
object(BcMath\Number)#2 (2) {
257-
["value"]=>
258-
string(5) "2.234"
259-
["scale"]=>
260-
int(3)
261-
}
262-
]]>
263-
</screen>
264-
</example>
265-
</refsect1>
266-
267157
<refsect1 role="seealso">
268158
&reftitle.seealso;
269159
<simplelist>

reference/bc/bcmath/number/ceil.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
</methodsynopsis>
1414
<simpara>
1515
Returns the next highest integer value by rounding up
16-
this object if necessary.
16+
<varname>$this</varname> if necessary.
1717
</simpara>
1818
</refsect1>
1919

2020
<refsect1 role="parameters">
2121
&reftitle.parameters;
22-
&no.function.parameters;</refsect1>
22+
&no.function.parameters;
23+
</refsect1>
2324

2425
<refsect1 role="returnvalues">
2526
&reftitle.returnvalues;

reference/bc/bcmath/number/compare.xml

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -103,99 +103,6 @@ int(0)
103103
</example>
104104
</refsect1>
105105

106-
<refsect1 role="bc.operatoroverload">
107-
<!-- operator overload title -->
108-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('bcmath-number.add')/db:refsect1[@role='bc.operatoroverload']/db:title)" />
109-
<simpara>
110-
<classname>BcMath\Number</classname> can perform comparison using operators. The comparison with
111-
the operator behaves the same as when the method argument <parameter>scale</parameter> is &null;.
112-
</simpara>
113-
<example>
114-
<title>Example of comparison using operators</title>
115-
<programlisting role="php">
116-
<![CDATA[
117-
<?php
118-
$number = new BcMath\Number('1.234');
119-
120-
echo 'case "=="' . PHP_EOL;
121-
var_dump(
122-
$number == new BcMath\Number('1.234'),
123-
$number == '1.23400',
124-
$number == '1.23401',
125-
$number == 1,
126-
);
127-
128-
echo PHP_EOL . 'case ">="' . PHP_EOL;
129-
var_dump(
130-
$number >= new BcMath\Number('1.234'),
131-
$number >= '1.23400',
132-
$number >= '1.23401',
133-
$number >= 1,
134-
);
135-
136-
echo PHP_EOL . 'case ">"' . PHP_EOL;
137-
var_dump(
138-
$number > new BcMath\Number('1.234'),
139-
$number > '1.23400',
140-
$number > '1.23401',
141-
$number > 1,
142-
);
143-
144-
echo PHP_EOL . 'case "<="' . PHP_EOL;
145-
var_dump(
146-
$number <= new BcMath\Number('1.234'),
147-
$number <= '1.23400',
148-
$number <= '1.23401',
149-
$number <= 1,
150-
);
151-
152-
echo PHP_EOL . 'case "<"' . PHP_EOL;
153-
var_dump(
154-
$number < new BcMath\Number('1.234'),
155-
$number < '1.23400',
156-
$number < '1.23401',
157-
$number < 1,
158-
);
159-
?>
160-
]]>
161-
</programlisting>
162-
&example.outputs;
163-
<screen>
164-
<![CDATA[
165-
case "=="
166-
bool(true)
167-
bool(true)
168-
bool(false)
169-
bool(false)
170-
171-
case ">="
172-
bool(true)
173-
bool(true)
174-
bool(false)
175-
bool(true)
176-
177-
case ">"
178-
bool(false)
179-
bool(false)
180-
bool(false)
181-
bool(true)
182-
183-
case "<="
184-
bool(true)
185-
bool(true)
186-
bool(true)
187-
bool(false)
188-
189-
case "<"
190-
bool(false)
191-
bool(false)
192-
bool(true)
193-
bool(false)
194-
]]>
195-
</screen>
196-
</example>
197-
</refsect1>
198-
199106
<refsect1 role="seealso">
200107
&reftitle.seealso;
201108
<simplelist>

0 commit comments

Comments
 (0)