Clarify MidpointRounding docs: round-to-nearest vs directed rounding#12875
Open
tannergooding with Copilot wants to merge 2 commits into
Open
Clarify MidpointRounding docs: round-to-nearest vs directed rounding#12875tannergooding with Copilot wants to merge 2 commits into
tannergooding with Copilot wants to merge 2 commits into
Conversation
Copilot created this pull request from a session on behalf of
tannergooding
July 11, 2026 22:47
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR clarifies the documentation for System.MidpointRounding by explicitly distinguishing round-to-nearest modes (only differ at midpoints) from directed rounding modes (apply to all values), addressing confusion stemming from the enum’s name.
Changes:
- Adds an upfront explanation in the type remarks contrasting round-to-nearest vs directed rounding.
- Strengthens the directed-rounding section with explicit “applies to every value” wording and a concrete example.
- Updates individual enum-field summaries to call out midpoint vs non-midpoint behavior and adds common aliases (e.g., “banker’s rounding”).
Show a summary per file
| File | Description |
|---|---|
| xml/System/MidpointRounding.xml | Refines the enum remarks and field summaries to better explain which modes affect only midpoints vs all values. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
MidpointRoundingname implies every mode only affects midpoints, but three of its five modes (ToNegativeInfinity,ToPositiveInfinity,ToZero) are directed-rounding modes that round every value in a fixed direction. Resolves dotnet/runtime#38160, which covers the current docs bury this distinction and the individual field summaries don't call it out.Changes to
xml/System/MidpointRounding.xml:ToPositiveInfinityrounds 2.1, 2.5, and 2.8 all up to 3).AwayFromZero/ToEvensummaries: Noted that non-midpoint values are rounded to nearest regardless of the choice; added "banker's rounding" alias forToEven.ToNegativeInfinity/ToPositiveInfinity/ToZerosummaries: Made explicit that every value (not just midpoints) is rounded in the given direction, and referenced the familiar equivalents (floor, ceiling, truncation).