Skip to content

Document .NET 11 breaking change: Math.Round/MathF.Round with digits - #55228

Merged
gewarren merged 3 commits into
mainfrom
copilot/breaking-change-math-round-correct-results
Aug 5, 2026
Merged

Document .NET 11 breaking change: Math.Round/MathF.Round with digits#55228
gewarren merged 3 commits into
mainfrom
copilot/breaking-change-math-round-correct-results

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Math.Round(double, int[, MidpointRounding]) and MathF.Round(float, int[, MidpointRounding]) now round based on the exact value of the input rather than a value * 10^digits scaling approximation, changing results for some inputs; the digits cap (0-15 for double, 0-6 for float) has also been removed, so only negative values throw.

Changes

  • New article docs/core/compatibility/core-libraries/11/math-round-digits.md — covers version introduced (.NET 11 Preview 7), previous vs. new behavior with examples, change category, rationale (link to Fix incorrect rounding in Math.Round and MathF.Round with digits runtime#130574), recommended action, and affected APIs.
  • Index docs/core/compatibility/11.md — added row under Core .NET libraries.
  • TOC docs/core/compatibility/toc.yml — added entry in the .NET 11 Core .NET libraries section.

Behavior contrast documented:

Math.Round(655.925, 2, MidpointRounding.AwayFromZero);            // was 655.93,             now 655.92
Math.Round(1111111111111111.5, 1, MidpointRounding.AwayFromZero); // was 1111111111111111.6, now 1111111111111111.5
Math.Round(1.5, 16, MidpointRounding.ToEven);                     // was ArgumentOutOfRangeException, now 1.5

The article also notes that the corrected behavior flows through double.Round, float.Round, Half.Round, and NFloat.Round, and that the decimal and single-argument overloads are unaffected.


Internal previews

File Preview link
docs/core/compatibility/11.md docs/core/compatibility/11
docs/core/compatibility/core-libraries/11/math-round-digits.md docs/core/compatibility/core-libraries/11/math-round-digits
docs/core/compatibility/toc.yml docs/core/compatibility/toc

Copilot AI review requested due to automatic review settings August 4, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Math.Round and MathF.Round to return correctly rounded results Document .NET 11 breaking change: Math.Round/MathF.Round with digits Aug 4, 2026
Copilot AI requested a review from gewarren August 4, 2026 21:15
Comment thread docs/core/compatibility/core-libraries/11/math-round-digits.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/math-round-digits.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/math-round-digits.md Outdated
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@gewarren
gewarren marked this pull request as ready for review August 5, 2026 17:06
@gewarren
gewarren requested a review from a team as a code owner August 5, 2026 17:07
@gewarren
gewarren enabled auto-merge (squash) August 5, 2026 17:07
@gewarren
gewarren merged commit 277d0d8 into main Aug 5, 2026
12 checks passed
@gewarren
gewarren deleted the copilot/breaking-change-math-round-correct-results branch August 5, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: Math.Round/MathF.Round with digits return the correctly rounded result and accept any non-negative digit count

4 participants