Skip to content

Fix StringExtensions.SplitFloats incorrect float parsing#112897

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
PixelDough:mono-fix-SplitFloats
Nov 18, 2025
Merged

Fix StringExtensions.SplitFloats incorrect float parsing#112897
Repiteo merged 1 commit into
godotengine:masterfrom
PixelDough:mono-fix-SplitFloats

Conversation

@PixelDough

Copy link
Copy Markdown
Contributor

the current code assumes that float.Parse behaves the same as the internal C++ code, however without using "end" as part of the span, it will parse from index 0 to the end of the string, ignoring commas. for example, this causes it to parse "0,5,0" with divisor "," as [50, 50, 0], as the float.Parse method ignores commas in floats.

if another divisor is used, it throws a System.FormatException due to containing invalid characters, as it fails to account for the position of the divisor for the span.

@PixelDough PixelDough requested a review from a team as a code owner November 18, 2025 00:32
@fire fire changed the title fix StringExtensions.SplitFloats incorrect float parsing Fix StringExtensions.SplitFloats incorrect float parsing Nov 18, 2025
@raulsntos raulsntos added this to the 4.6 milestone Nov 18, 2025

@raulsntos raulsntos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks! I tested the changes and it works as expected.

You'll need to squash the commits before this PR can be merged. The contributing documentation contains information about squashing in case you need it.

Feel free to reach out in the development chat if you need help.

the current code assumes that float.Parse behaves the same as the
internal C++ code, however without using "end" as part of the span, it
will parse from index 0 to the end of the string, ignoring commas. for
example, this causes it to parse "0,5,0" with divisor "," as [50, 50,
0], as the float.Parse method ignores commas in floats.

if another divisor is used, it throws a System.FormatException due to
containing invalid characters, as it fails to account for the position
of the divisor for the span.
@Repiteo Repiteo merged commit ed62fb1 into godotengine:master Nov 18, 2025
20 checks passed
@Repiteo

Repiteo commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Thanks! Congratulations on your first merged contribution! 🎉

@PixelDough PixelDough deleted the mono-fix-SplitFloats branch November 18, 2025 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants