language/types/integer.xml
78a11d3ca004ee937549d932e77a79c51b9777cd
78a11d3ca004ee937549d932e77a79c51b9777cd
...
...
@@ -43,7 +43,7 @@
43
43
44
44
<example>
45
45
<title>Integer literals</title>
46
-
<programlisting role="php">
46
+
<programlisting role="php" annotations="non-interactive">
47
47
<![CDATA[
48
48
<?php
49
49
$a = 1234; // decimal number
...
...
@@ -133,7 +133,8 @@ var_dump(PHP_INT_MAX + 1); // 32-bit system: float(2147483648)
133
133
the <function>round</function> function provides finer control over rounding.
134
134
</para>
135
135
136
-
<informalexample>
136
+
<example>
137
+
<title>Divisions</title>
137
138
<programlisting role="php">
138
139
<![CDATA[
139
140
<?php
...
...
@@ -143,16 +144,15 @@ var_dump(round(25/7)); // float(4)
143
144
?>
144
145
]]>
145
146
</programlisting>
146
-
</informalexample>
147
+
</example>
147
148
</sect2>
148
149
149
150
<sect2 xml:id="language.types.integer.casting">
150
151
<title>Converting to integer</title>
151
152
152
153
<simpara>
153
-
To explicitly convert a value to <type>int</type>, use either the
154
-
<literal>(int)</literal> or <literal>(integer)</literal> casts. However, in
155
-
most cases the cast is not needed, since a value will be automatically
154
+
To explicitly convert a value to <type>int</type>, use the <literal>(int)</literal> cast.
155
+
However, in most cases the cast is not needed, since a value will be automatically
156
156
converted if an operator, function or control structure requires an
157
157
<type>int</type> argument. A value can also be converted to
158
158
<type>int</type> with the <function>intval</function> function.
...
...
@@ -188,7 +188,9 @@ var_dump(round(25/7)); // float(4)
188
188
As of PHP 8.1.0, a deprecation notice is emitted when implicitly converting a non-integral &float; to &integer; which loses precision.
189
189
</simpara>
190
190
191
-
<programlisting role="php">
191
+
<example>
192
+
<title>Casting from Float</title>
193
+
<programlisting role="php">
192
194
<![CDATA[
193
195
<?php
194
196
...
...
@@ -204,7 +206,8 @@ var_dump((int) 8.1); // 8 in both cases
204
206
var_dump(intval(8.1)); // 8 in both cases
205
207
?>
206
208
]]>
207
-
</programlisting>
209
+
</programlisting>
210
+
</example>
208
211
209
212
<para>
210
213
If the float is beyond the boundaries of <type>int</type> (usually
211
214