Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: Complex.ToString format changed from (a, b) to <a; b> #41835

Closed
1 of 3 tasks
jeffhandley opened this issue Jul 19, 2024 · 0 comments · Fixed by #42052
Closed
1 of 3 tasks

[Breaking change]: Complex.ToString format changed from (a, b) to <a; b> #41835

jeffhandley opened this issue Jul 19, 2024 · 0 comments · Fixed by #42052
Assignees
Labels
breaking-change Indicates a .NET Core breaking change doc-idea Indicates issues that are suggestions for new topics [org][type][category] in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@jeffhandley
Copy link
Member

jeffhandley commented Jul 19, 2024

Description

To better support formatting values with culture-specific information, the default string representation of complex numbers was changed to avoid using characters that can be used in formatted numeric values. This change affects Complex.ToString, where the value is now formatted as <a; b> instead of (a, b).

This breaking change did not get an issue created at the time of .NET 8 GA, but was reported in dotnet/runtime#93454.

Version

.NET 8 GA

Previous behavior

The string representation of the complex number returned by Complex.ToString displays the number using its Cartesian coordinates in the form (a, b), where a is the real part of the complex number, and b is its imaginary part. Both a and b are formatted using the general format specifier ("G") and the conventions of the culture defined by provider.

New behavior

The string representation of the complex number returned by Complex.ToString displays the number using its Cartesian coordinates in the form <a; b>, where a is the real part of the complex number, and b is its imaginary part. Both a and b are formatted using the general format specifier ("G") and the conventions of the culture defined by provider.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

The change to use semicolon allows support of formatting with culture specific information and correspondingly need to be able to parse results back out given it implements INumberBase<T>.

The change from parentheses (( )) to angle brackets avoids potential collision with numeric formats where negative numbers are formatted as (x), and this is also consistent with the Vector* types' behavior.

Recommended action

If the previous format is needed, a custom string formatting mechanism such as $"({complex.Real}, {complex.Imaginary})" can be used to produce the string in the old format.

Feature area

Core .NET libraries

Affected APIs


Associated WorkItem - 292108

@jeffhandley jeffhandley added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Jul 19, 2024
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged labels Jul 19, 2024
jeffhandley added a commit to jeffhandley/dotnet-api-docs that referenced this issue Jul 19, 2024
Per dotnet/docs#41835, the format from Complex.ToString changed in .NET 8 from (a, b) to <a; b>
BillWagner pushed a commit to dotnet/dotnet-api-docs that referenced this issue Jul 19, 2024
Per dotnet/docs#41835, the format from Complex.ToString changed in .NET 8 from (a, b) to <a; b>
@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Aug 1, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Aug 1, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Aug 1, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change doc-idea Indicates issues that are suggestions for new topics [org][type][category] in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants