Skip to content

Commit 70ce877

Browse files
round関係のenのupdateに追随 (#263)
1 parent e6bdf3c commit 70ce877

File tree

3 files changed

+84
-15
lines changed

3 files changed

+84
-15
lines changed

reference/bc/bcmath/number/round.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: a414ee95eb79e2c62c80827a46e15da5d15af97e Maintainer: saki Status: ready -->
3+
<!-- EN-Revision: 15b93836d93f01ea6d90a68cacf04ce0d9fb8eff Maintainer: saki Status: ready -->
44

55
<refentry xml:id="bcmath-number.round" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
66
<refnamediv>
@@ -26,11 +26,11 @@
2626
<variablelist>
2727
<!-- precision parameter -->
2828
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.round')/db:refsect1[@role='parameters']/descendant::db:varlistentry[2])" />
29-
<varlistentry>
29+
<varlistentry xml:id="bcmath-number.round..parameters.mode">
3030
<term><parameter>mode</parameter></term>
3131
<listitem>
3232
<simpara>
33-
指定する丸めモード。
33+
指定する丸めモード。詳しくは <enumname>RoundingMode</enumname> を参照してください。
3434
</simpara>
3535
</listitem>
3636
</varlistentry>

reference/bc/functions/bcround.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: a414ee95eb79e2c62c80827a46e15da5d15af97e Maintainer: saki Status: ready -->
3+
<!-- EN-Revision: 15b93836d93f01ea6d90a68cacf04ce0d9fb8eff Maintainer: saki Status: ready -->
44

55
<refentry xml:id="function.bcround" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
66
<refnamediv>
@@ -27,14 +27,7 @@
2727
<variablelist>
2828
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.round')/db:refsect1[@role='parameters']/descendant::db:varlistentry[1])" />
2929
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.round')/db:refsect1[@role='parameters']/descendant::db:varlistentry[2])" />
30-
<varlistentry>
31-
<term><parameter>mode</parameter></term>
32-
<listitem>
33-
<simpara>
34-
指定する丸めモード。
35-
</simpara>
36-
</listitem>
37-
</varlistentry>
30+
<xi:include xpointer="bcmath-number.round..parameters.mode" />
3831
</variablelist>
3932
</refsect1>
4033

reference/math/functions/round.xml

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 6406cc6c50f8f66f7d55f550dc1ec2759e2eca0f Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 15b93836d93f01ea6d90a68cacf04ce0d9fb8eff Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: takagi,mumumu -->
55
<refentry xml:id="function.round" xmlns="http://docbook.org/ns/docbook">
66
<refnamediv>
@@ -13,7 +13,7 @@
1313
<type>float</type><methodname>round</methodname>
1414
<methodparam><type class="union"><type>int</type><type>float</type></type><parameter>num</parameter></methodparam>
1515
<methodparam choice="opt"><type>int</type><parameter>precision</parameter><initializer>0</initializer></methodparam>
16-
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer><constant>PHP_ROUND_HALF_UP</constant></initializer></methodparam>
16+
<methodparam choice="opt"><type class="union"><type>int</type><type>RoundingMode</type></type><parameter>mode</parameter><initializer>RoundingMode::HalfAwayFromZero</initializer></methodparam>
1717
</methodsynopsis>
1818
<para>
1919
<parameter>num</parameter> を、指定した
@@ -76,7 +76,7 @@
7676
<term><parameter>mode</parameter></term>
7777
<listitem>
7878
<para>
79-
次の定数のいずれかを使って、丸めのモードを指定します。
79+
<enumname>RoundingMode</enumname> もしくは次の定数のいずれかを使って、丸めのモードを指定します。
8080
<informaltable>
8181
<tgroup cols="2">
8282
<thead>
@@ -121,6 +121,7 @@
121121
</tbody>
122122
</tgroup>
123123
</informaltable>
124+
ただし、新規に追加されたいくつかのモードは <enumname>RoundingMode</enumname> にのみ存在します。
124125
</para>
125126
</listitem>
126127
</varlistentry>
@@ -134,6 +135,14 @@
134135
</para>
135136
</refsect1>
136137

138+
<refsect1 role="errors">
139+
&reftitle.errors;
140+
<simpara>
141+
この関数は、無効な <parameter>mode</parameter> が指定された場合に <exceptionname>ValueError</exceptionname> をスローします。
142+
PHP 8.4.0 より前では、、エラーにはならずに <constant>PHP_ROUND_HALF_UP</constant> を使用していました。
143+
</simpara>
144+
</refsect1>
145+
137146
<refsect1 role="changelog">
138147
&reftitle.changelog;
139148
<informaltable>
@@ -145,6 +154,18 @@
145154
</row>
146155
</thead>
147156
<tbody>
157+
<row>
158+
<entry>8.4.0</entry>
159+
<entry>
160+
新しい4つのモードが追加されました。
161+
</entry>
162+
</row>
163+
<row>
164+
<entry>8.4.0</entry>
165+
<entry>
166+
無効な <parameter>mode</parameter> が指定された場合に <exceptionname>ValueError</exceptionname> をスローするようになりました。
167+
</entry>
168+
</row>
148169
<row>
149170
<entry>8.0.0</entry>
150171
<entry>
@@ -314,6 +335,61 @@ float(-1.5)
314335
]]>
315336
</screen>
316337
</example>
338+
<example>
339+
<title><enumname>RoundingMode</enumname> を使用した例</title>
340+
<programlisting role="php">
341+
<![CDATA[
342+
<?php
343+
foreach (RoundingMode::cases() as $mode) {
344+
foreach ([
345+
8.5,
346+
9.5,
347+
-3.5,
348+
] as $number) {
349+
printf("%-17s: %+.17g -> %+.17g\n", $mode->name, $number, round($number, 0, $mode));
350+
}
351+
echo "\n";
352+
}
353+
?>
354+
]]>
355+
</programlisting>
356+
&example.outputs;
357+
<screen role="php">
358+
<![CDATA[
359+
HalfAwayFromZero : +8.5 -> +9
360+
HalfAwayFromZero : +9.5 -> +10
361+
HalfAwayFromZero : -3.5 -> -4
362+
363+
HalfTowardsZero : +8.5 -> +8
364+
HalfTowardsZero : +9.5 -> +9
365+
HalfTowardsZero : -3.5 -> -3
366+
367+
HalfEven : +8.5 -> +8
368+
HalfEven : +9.5 -> +10
369+
HalfEven : -3.5 -> -4
370+
371+
HalfOdd : +8.5 -> +9
372+
HalfOdd : +9.5 -> +9
373+
HalfOdd : -3.5 -> -3
374+
375+
TowardsZero : +8.5 -> +8
376+
TowardsZero : +9.5 -> +9
377+
TowardsZero : -3.5 -> -3
378+
379+
AwayFromZero : +8.5 -> +9
380+
AwayFromZero : +9.5 -> +10
381+
AwayFromZero : -3.5 -> -4
382+
383+
NegativeInfinity : +8.5 -> +8
384+
NegativeInfinity : +9.5 -> +9
385+
NegativeInfinity : -3.5 -> -4
386+
387+
PositiveInfinity : +8.5 -> +9
388+
PositiveInfinity : +9.5 -> +10
389+
PositiveInfinity : -3.5 -> -3
390+
]]>
391+
</screen>
392+
</example>
317393
</para>
318394
</refsect1>
319395

0 commit comments

Comments
 (0)