Skip to content

Commit c35ad60

Browse files
authored
Add tags for arithmetic operator page (#4101)
Slightly change wording
1 parent 2f3041d commit c35ad60

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

language/operators/arithmetic.xml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,58 @@
1818
</thead>
1919
<tbody>
2020
<row>
21-
<entry>+$a</entry>
21+
<entry><code>+$a</code></entry>
2222
<entry>Identity</entry>
2323
<entry>
2424
Conversion of <varname>$a</varname> to <type>int</type> or
2525
<type>float</type> as appropriate.
2626
</entry>
2727
</row>
2828
<row>
29-
<entry>-$a</entry>
29+
<entry><code>-$a</code></entry>
3030
<entry>Negation</entry>
3131
<entry>Opposite of <varname>$a</varname>.</entry>
3232
</row>
3333
<row>
34-
<entry>$a + $b</entry>
34+
<entry><code>$a + $b</code></entry>
3535
<entry>Addition</entry>
3636
<entry>Sum of <varname>$a</varname> and <varname>$b</varname>.</entry>
3737
</row>
3838
<row>
39-
<entry>$a - $b</entry>
39+
<entry><code>$a - $b</code></entry>
4040
<entry>Subtraction</entry>
4141
<entry>Difference of <varname>$a</varname> and <varname>$b</varname>.</entry>
4242
</row>
4343
<row>
44-
<entry>$a * $b</entry>
44+
<entry><code>$a * $b</code></entry>
4545
<entry>Multiplication</entry>
4646
<entry>Product of <varname>$a</varname> and <varname>$b</varname>.</entry>
4747
</row>
4848
<row>
49-
<entry>$a / $b</entry>
49+
<entry><code>$a / $b</code></entry>
5050
<entry>Division</entry>
5151
<entry>Quotient of <varname>$a</varname> and <varname>$b</varname>.</entry>
5252
</row>
5353
<row>
54-
<entry>$a % $b</entry>
54+
<entry><code>$a % $b</code></entry>
5555
<entry>Modulo</entry>
5656
<entry>Remainder of <varname>$a</varname> divided by <varname>$b</varname>.</entry>
5757
</row>
5858
<row>
59-
<entry>$a ** $b</entry>
59+
<entry><code>$a ** $b</code></entry>
6060
<entry>Exponentiation</entry>
6161
<entry>Result of raising <varname>$a</varname> to the <varname>$b</varname>'th power.</entry>
6262
</row>
6363
</tbody>
6464
</tgroup>
6565
</table>
6666
<simpara>
67-
The division operator ("/") returns a float value unless the two operands
68-
are integers (or strings that get converted to integers) and the numbers
69-
are evenly divisible, in which case an integer value will be returned. For
70-
integer division, see <function>intdiv</function>.
67+
The division operator <literal>/</literal> returns a <type>float</type>
68+
value unless the two operands are <type>int</type> (or
69+
<link linkend="language.types.numeric-strings">numeric strings</link>
70+
which are type juggled to <type>int</type>) and the numerator is a multiple
71+
of the divisor, in which case an integer value will be returned.
72+
For integer division, see <function>intdiv</function>.
7173
</simpara>
7274
<simpara>
7375
Operands of modulo are converted to <type>int</type>
@@ -76,21 +78,30 @@
7678
</simpara>
7779
<para>
7880
The result of the modulo operator <literal>%</literal> has the same sign
79-
as the dividend — that is, the result of <literal>$a % $b</literal>
81+
as the dividend — that is, the result of <code>$a % $b</code>
8082
will have the same sign as <varname>$a</varname>. For example:
8183
<informalexample>
8284
<programlisting role="php">
8385
<![CDATA[
8486
<?php
8587
86-
echo (5 % 3)."\n"; // prints 2
87-
echo (5 % -3)."\n"; // prints 2
88-
echo (-5 % 3)."\n"; // prints -2
89-
echo (-5 % -3)."\n"; // prints -2
88+
var_dump(5 % 3);
89+
var_dump(5 % -3);
90+
var_dump(-5 % 3);
91+
var_dump(-5 % -3);
9092
9193
?>
9294
]]>
9395
</programlisting>
96+
&example.outputs;
97+
<screen>
98+
<![CDATA[
99+
int(2)
100+
int(2)
101+
int(-2)
102+
int(-2)
103+
]]>
104+
</screen>
94105
</informalexample>
95106
</para>
96107
<sect2 role="seealso">

0 commit comments

Comments
 (0)