Skip to content

Fix three accuracy issues in System.Double article#52882

Open
Copilot wants to merge 7 commits intomainfrom
copilot/update-system-double-article
Open

Fix three accuracy issues in System.Double article#52882
Copilot wants to merge 7 commits intomainfrom
copilot/update-system-double-article

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Three factual/clarity issues in the System.Double reference article: missing .NET 10 behavior note, unexplained divisor logic in IsApproximatelyEqual, and an incorrect claim about integral-type exceptions.

Changes

  • "R" format specifier note: Adds that starting with .NET 10 (C# 14), ToString() without any format specifier already outputs all 17 significant digits—making the disparity visible without "R".

  • IsApproximatelyEqual divisor explanation: Expands the prose before the code snippet to explain why the method divides by Math.Max(value1, value2) (normalizes to the larger value's order of magnitude) and why it falls back to Math.Min (handles the case where one value is zero and the other is negative, preventing division by zero).

  • Floating-point exceptions section: Rewrites the opening sentence to correctly distinguish:

    • Integer division by zero → always throws DivideByZeroException
    • Integer overflow → throws OverflowException only in a checked context (C# default is unchecked)

    Old (inaccurate):

    Unlike operations with integral types, which throw exceptions in cases of overflow or illegal operations such as division by zero, operations with floating-point values do not throw exceptions.

    New:

    Unlike operations with integral types—which throw a DivideByZeroException for division by zero, or throw an OverflowException for overflow in a checked context (by default in C#, integer overflow doesn't throw)—operations with floating-point values don't throw exceptions.


Internal previews

📄 File 🔗 Preview link
docs/fundamentals/runtime-libraries/system-double.md System.Double struct

Copilot AI linked an issue Apr 6, 2026 that may be closed by this pull request
…Equal explanation, and exceptions section accuracy

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/98ba24d1-4717-489d-9983-54d0dbdb6a73

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve comments on the System.Double article Fix three accuracy issues in System.Double article Apr 6, 2026
Copilot AI requested a review from gewarren April 6, 2026 21:21
@gewarren gewarren marked this pull request as ready for review April 6, 2026 21:34
@gewarren gewarren requested a review from a team as a code owner April 6, 2026 21:34
Copilot AI review requested due to automatic review settings April 6, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the System.Double reference article to correct and clarify several accuracy points around floating-point formatting, approximate comparisons, and exception behavior, improving reader understanding of common pitfalls.

Changes:

  • Adds a note about .NET 10 output formatting behavior relative to the "R" format specifier.
  • Expands the explanation for the IsApproximatelyEqual sample’s divisor selection logic.
  • Corrects the explanation of how integral-type operations throw exceptions (division by zero, and overflow in checked contexts).

Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM. Let's :shipit:

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.

Comments on the System.Double article

4 participants