language/types/float.xml
a1e3d629b4f01ee41bd38391cd5c6ae5ee894cb3
...
...
@@ -29,7 +29,7 @@ $d = 1_234.567; // as of PHP 7.4.0
29
29
<programlisting>
30
30
<![CDATA[
31
31
LNUM [0-9]+(_[0-9]+)*
32
-
DNUM ([0-9]*(_[0-9]+)*[\.]{LNUM}) | ({LNUM}[\.][0-9]*(_[0-9]+)*)
32
+
DNUM ({LNUM}?"."{LNUM}) | ({LNUM}"."{LNUM}?)
33
33
EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
34
34
]]>
35
35
</programlisting>
...
...
@@ -82,17 +82,36 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
82
82
<sect2 xml:id="language.types.float.casting">
83
83
<title>Converting to float</title>
84
84

85
-
<para>
86
-
For information on converting <type>string</type>s to <type>float</type>, see
87
-
<link linkend="language.types.string.conversion">String conversion to
88
-
numbers</link>. For values of other types, the conversion is performed by
89
-
converting the value to <type>integer</type> first and then to
90
-
<type>float</type>. See
91
-
<link linkend="language.types.integer.casting">Converting to integer</link>
92
-
for more information. As of PHP 5, a notice is thrown if an
93
-
<type>object</type> is converted to <type>float</type>.
94
-
</para>
85
+
<sect3 xml:id="language.types.float.casting.from-string">
86
+
<title>From strings</title>
95
87

88
+
<simpara>
89
+
If the string is
90
+
<link linkend="language.types.numeric-strings">numeric</link>
91
+
or leading numeric then it will resolve to the
92
+
corresponding float value, otherwise it is converted to zero
93
+
(<literal>0</literal>).
94
+
</simpara>
95
+
</sect3>
96
+

97
+
<sect3 xml:id="language.types.float.casting.from-other">
98
+
<title>From other types</title>
99
+

100
+
<para>
101
+
For values of other types, the conversion is performed by converting the
102
+
value to <type>int</type> first and then to <type>float</type>. See
103
+
<link linkend="language.types.integer.casting">Converting to integer</link>
104
+
for more information.
105
+
</para>
106
+

107
+
<note>
108
+
<para>
109
+
As certain types have undefined behavior when converting to
110
+
<type>int</type>, this is also the case when converting to
111
+
<type>float</type>.
112
+
</para>
113
+
</note>
114
+
</sect3>
96
115
</sect2>
97
116

98
117
<sect2 xml:id="language.types.float.comparison">
99
118