From 61408f1494112adaac20648cd98001b9b194bbfd Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:46:52 +0200 Subject: [PATCH] [Docs] Clarify that `String` parsing methods don't support num separators --- doc/classes/String.xml | 8 ++++++++ doc/classes/StringName.xml | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 40f08dafe69..7882b9cb9b9 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -66,11 +66,13 @@ print("101".bin_to_int()) # Prints 5 print("0b101".bin_to_int()) # Prints 5 print("-0b10".bin_to_int()) # Prints -2 + print("1_0".bin_to_int()) # Prints 0 (number separators are not supported) [/gdscript] [csharp] GD.Print("101".BinToInt()); // Prints 5 GD.Print("0b101".BinToInt()); // Prints 5 GD.Print("-0b10".BinToInt()); // Prints -2 + GD.Print("1_0".BinToInt()); // Prints 0 (number separators are not supported) [/csharp] [/codeblocks] @@ -378,10 +380,12 @@ [gdscript] print("0xff".hex_to_int()) # Prints 255 print("ab".hex_to_int()) # Prints 171 + print("a_b".hex_to_int()) # Prints 0 (number separators are not supported) [/gdscript] [csharp] GD.Print("0xff".HexToInt()); // Prints 255 GD.Print("ab".HexToInt()); // Prints 171 + GD.Print("a_b".HexToInt()); // Prints 0 (number separators are not supported) [/csharp] [/codeblocks] @@ -479,6 +483,7 @@ print("24".is_valid_float()) # Prints true print("7e3".is_valid_float()) # Prints true print("Hello".is_valid_float()) # Prints false + print("2_4".is_valid_float()) # Prints false (number separators are not supported) [/codeblock] @@ -492,6 +497,7 @@ print("A08E".is_valid_hex_number()) # Prints true print("-AbCdEf".is_valid_hex_number()) # Prints true print("2.5".is_valid_hex_number()) # Prints false + print("2_5".is_valid_hex_number()) # Prints false (number separators are not supported) print("0xDEADC0DE".is_valid_hex_number(true)) # Prints true [/codeblock] @@ -525,6 +531,7 @@ print("Hi".is_valid_int()) # Prints false print("+3".is_valid_int()) # Prints true print("-12".is_valid_int()) # Prints true + print("1_2".is_valid_int()) # Prints false (number separators are not supported) [/codeblock] @@ -988,6 +995,7 @@ var c = "12xy3".to_float() # c is 12.0 var d = "1e3".to_float() # d is 1000.0 var e = "Hello!".to_float() # e is 0.0 + var f = "1_2".to_float() # f is 1.0 (number separators are not supported) [/codeblock] diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml index 3a2b4924961..4c8f4017fc4 100644 --- a/doc/classes/StringName.xml +++ b/doc/classes/StringName.xml @@ -61,11 +61,13 @@ print("101".bin_to_int()) # Prints 5 print("0b101".bin_to_int()) # Prints 5 print("-0b10".bin_to_int()) # Prints -2 + print("1_0".bin_to_int()) # Prints 0 (number separators are not supported) [/gdscript] [csharp] GD.Print("101".BinToInt()); // Prints 5 GD.Print("0b101".BinToInt()); // Prints 5 GD.Print("-0b10".BinToInt()); // Prints -2 + GD.Print("1_0".BinToInt()); // Prints 0 (number separators are not supported) [/csharp] [/codeblocks] @@ -355,10 +357,12 @@ [gdscript] print("0xff".hex_to_int()) # Prints 255 print("ab".hex_to_int()) # Prints 171 + print("a_b".hex_to_int()) # Prints 0 (number separators are not supported) [/gdscript] [csharp] GD.Print("0xff".HexToInt()); // Prints 255 GD.Print("ab".HexToInt()); // Prints 171 + GD.Print("a_b".HexToInt()); // Prints 0 (number separators are not supported) [/csharp] [/codeblocks] @@ -448,6 +452,7 @@ print("24".is_valid_float()) # Prints true print("7e3".is_valid_float()) # Prints true print("Hello".is_valid_float()) # Prints false + print("2_4".is_valid_float()) # Prints false (number separators are not supported) [/codeblock] @@ -461,6 +466,7 @@ print("A08E".is_valid_hex_number()) # Prints true print("-AbCdEf".is_valid_hex_number()) # Prints true print("2.5".is_valid_hex_number()) # Prints false + print("2_5".is_valid_hex_number()) # Prints false (number separators are not supported) print("0xDEADC0DE".is_valid_hex_number(true)) # Prints true [/codeblock] @@ -494,6 +500,7 @@ print("Hi".is_valid_int()) # Prints false print("+3".is_valid_int()) # Prints true print("-12".is_valid_int()) # Prints true + print("1_2".is_valid_int()) # Prints false (number separators are not supported) [/codeblock] @@ -885,11 +892,12 @@ Converts the string representing a decimal number into a [float]. This method stops on the first non-number character, except the first decimal point ([code].[/code]) and the exponent letter ([code]e[/code]). See also [method is_valid_float]. [codeblock] - var a = "12.35".to_float() # a is 12.35 - var b = "1.2.3".to_float() # b is 1.2 - var c = "12xy3".to_float() # c is 12.0 - var d = "1e3".to_float() # d is 1000.0 - var e = "Hello!".to_int() # e is 0.0 + var a = "12.35".to_float() # a is 12.35 + var b = "1.2.3".to_float() # b is 1.2 + var c = "12xy3".to_float() # c is 12.0 + var d = "1e3".to_float() # d is 1000.0 + var e = "Hello!".to_float() # e is 0.0 + var f = "1_2".to_float() # f is 1.0 (number separators are not supported) [/codeblock]