summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-17 17:25:05 +0100
committerGitHub <noreply@github.com>2022-01-17 17:25:05 +0100
commit324dca57af03df66b6314cc29f46f8ebb4ec59b2 (patch)
treea73b088b31767ae64589f40cccee63e190671d27
parent24f8a5979c5cfab3f7b3bccdfb27973918d3ae0c (diff)
parent7bb682651f1dca4bc4a7a1b8ff67e6c9e288dc54 (diff)
Merge pull request #56828 from KoBeWi/7H15_15_NUMB3R
-rw-r--r--doc/classes/String.xml15
1 files changed, 13 insertions, 2 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index d86c577e5e..c8e835f0f1 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -684,13 +684,24 @@
<method name="to_float" qualifiers="const">
<return type="float" />
<description>
- Converts a string containing a decimal number into a [code]float[/code].
+ Converts a string containing a decimal number into a [code]float[/code]. The method will stop on the first non-number character except the first [code].[/code] (decimal point), and [code]e[/code] which is used for exponential.
+ [codeblock]
+ print("12.3".to_float()) # 12.3
+ print("1.2.3".to_float()) # 1.2
+ print("12ab3".to_float()) # 12
+ print("1e3".to_float()) # 1000
+ [/codeblock]
</description>
</method>
<method name="to_int" qualifiers="const">
<return type="int" />
<description>
- Converts a string containing an integer number into an [code]int[/code].
+ Converts a string containing an integer number into an [code]int[/code]. The method will remove any non-number character and stop if it encounters a [code].[/code].
+ [codeblock]
+ print("123".to_int()) # 123
+ print("a1b2c3".to_int()) # 123
+ print("1.2.3".to_int()) # 1
+ [/codeblock]
</description>
</method>
<method name="to_lower" qualifiers="const">