Merge pull request #34328 from Dancovich/patch-1

Clarifying how float(String from) parses partially invalid strings
This commit is contained in:
Rémi Verschelde 2019-12-13 15:47:18 +01:00 committed by GitHub
commit 37f664b1a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,7 @@
<argument index="0" name="from" type="String"> <argument index="0" name="from" type="String">
</argument> </argument>
<description> <description>
Cast a [String] value to a floating-point value. This method accepts float value strings like [code]"1.23"[/code] and exponential notation strings for its parameter so calling [code]float("1e3")[/code] will return 1000.0 and calling [code]float("1e-3")[/code] will return 0.001. Cast a [String] value to a floating-point value. This method accepts float value strings like [code]"1.23"[/code] and exponential notation strings for its parameter so calling [code]float("1e3")[/code] will return 1000.0 and calling [code]float("1e-3")[/code] will return 0.001. Calling this method with an invalid float string will return 0. This method stops parsing at the first invalid character and will return the parsed result so far, so calling [code]float("1a3")[/code] will return 1 while calling [code]float("1e3a2")[/code] will return 1000.0.
</description> </description>
</method> </method>
</methods> </methods>