reference/bc/functions/bcmod.xml
4754397753fd79f1c846868b66a2448babab1c54
...
...
@@ -10,12 +10,15 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>bcmod</methodname>
13
-
<methodparam><type>string</type><parameter>left_operand</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>modulus</parameter></methodparam>
13
+
<methodparam><type>string</type><parameter>num1</parameter></methodparam>
14
+
<methodparam><type>string</type><parameter>num2</parameter></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>scale</parameter><initializer>&null;</initializer></methodparam>
15
16
</methodsynopsis>
16
17
<para>
17
-
Get the modulus of the <parameter>left_operand</parameter> using
18
-
<parameter>modulus</parameter>.
18
+
Get the remainder of dividing <parameter>num1</parameter> by
19
+
<parameter>num2</parameter>.
20
+
Unless <parameter>num2</parameter> is zero, the result has the same sign
21
+
as <parameter>num1</parameter>.
19
22
</para>
20
23
</refsect1>
21
24

...
...
@@ -24,18 +27,18 @@
24
27
<para>
25
28
<variablelist>
26
29
<varlistentry>
27
-
<term><parameter>left_operand</parameter></term>
30
+
<term><parameter>num1</parameter></term>
28
31
<listitem>
29
32
<para>
30
-
The left operand, as a string.
33
+
The dividend, as a string.
31
34
</para>
32
35
</listitem>
33
36
</varlistentry>
34
37
<varlistentry>
35
-
<term><parameter>modulus</parameter></term>
38
+
<term><parameter>num2</parameter></term>
36
39
<listitem>
37
40
<para>
38
-
The modulus, as a string.
41
+
The divisor, as a string.
39
42
</para>
40
43
</listitem>
41
44
</varlistentry>
...
...
@@ -47,10 +50,47 @@
47
50
&reftitle.returnvalues;
48
51
<para>
49
52
Returns the modulus as a string, or &null; if
50
-
<parameter>modulus</parameter> is 0.
53
+
<parameter>num2</parameter> is <literal>0</literal>.
51
54
</para>
52
55
</refsect1>
53
56
57
+
<refsect1 role="changelog"><!-- {{{ -->
58
+
&reftitle.changelog;
59
+
<informaltable>
60
+
<tgroup cols="2">
61
+
<thead>
62
+
<row>
63
+
<entry>&Version;</entry>
64
+
<entry>&Description;</entry>
65
+
</row>
66
+
</thead>
67
+
<tbody>
68
+
<row>
69
+
<entry>8.0.0</entry>
70
+
<entry>
71
+
<parameter>scale</parameter> is now nullable.
72
+
</entry>
73
+
</row>
74
+
<row>
75
+
<entry>7.2.0</entry>
76
+
<entry>
77
+
<parameter>num1</parameter> and <parameter>num2</parameter> are no
78
+
longer truncated to integer, so now the behavior of
79
+
<function>bcmod</function> follows <function>fmod</function> rather than
80
+
the <literal>%</literal> operator.
81
+
</entry>
82
+
</row>
83
+
<row>
84
+
<entry>7.2.0</entry>
85
+
<entry>
86
+
The <parameter>scale</parameter> parameter was added.
87
+
</entry>
88
+
</row>
89
+
</tbody>
90
+
</tgroup>
91
+
</informaltable>
92
+
</refsect1><!-- }}} -->
93
+

54
94
<refsect1 role="examples">
55
95
&reftitle.examples;
56
96
<example>
...
...
@@ -58,8 +98,22 @@
58
98
<programlisting role="php">
59
99
<![CDATA[
60
100
<?php
61
-
echo bcmod('4', '2'); // 0
62
-
echo bcmod('2', '4'); // 2
101
+
bcscale(0);
102
+
echo bcmod( '5', '3'); // 2
103
+
echo bcmod( '5', '-3'); // 2
104
+
echo bcmod('-5', '3'); // -2
105
+
echo bcmod('-5', '-3'); // -2
106
+
?>
107
+
]]>
108
+
</programlisting>
109
+
</example>
110
+
<example>
111
+
<title><function>bcmod</function> with decimals</title>
112
+
<programlisting role="php">
113
+
<![CDATA[
114
+
<?php
115
+
bcscale(1);
116
+
echo bcmod('5.7', '1.3'); // 0.5 as of PHP 7.2.0; 0 previously
63
117
?>
64
118
]]>
65
119
</programlisting>
...
...
@@ -75,7 +129,6 @@ echo bcmod('2', '4'); // 2
75
129
</para>
76
130
</refsect1>
77
131
</refentry>
78
-

79
132
<!-- Keep this comment at the end of the file
80
133
Local variables:
81
134
mode: sgml
82
135