Fix three accuracy issues in System.Double article#52882
Open
Fix three accuracy issues in System.Double article#52882
Conversation
…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
gewarren
approved these changes
Apr 6, 2026
Contributor
There was a problem hiding this comment.
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 10output formatting behavior relative to the"R"format specifier. - Expands the explanation for the
IsApproximatelyEqualsample’s divisor selection logic. - Corrects the explanation of how integral-type operations throw exceptions (division by zero, and overflow in checked contexts).
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.
Three factual/clarity issues in the
System.Doublereference article: missing .NET 10 behavior note, unexplained divisor logic inIsApproximatelyEqual, 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".IsApproximatelyEqualdivisor explanation: Expands the prose before the code snippet to explain why the method divides byMath.Max(value1, value2)(normalizes to the larger value's order of magnitude) and why it falls back toMath.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:
DivideByZeroExceptionOverflowExceptiononly in a checked context (C# default is unchecked)Old (inaccurate):
New:
Internal previews