Skip to content

Conversation

@gewarren
Copy link
Contributor

@gewarren gewarren commented Jan 24, 2026

Fixes #51294.


Internal previews

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

@gewarren gewarren requested a review from a team as a code owner January 24, 2026 01:52
Copilot AI review requested due to automatic review settings January 24, 2026 01:52
@dotnetrepoman dotnetrepoman bot added this to the January 2026 milestone Jan 24, 2026
Copy link
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

Updates the System.Single documentation and its referenced snippets so the described behavior and the displayed example output match current .NET behavior (Fixes #51294).

Changes:

  • Updated article text to better match snippet behavior, and refreshed several API cross-references.
  • Updated multiple snippet files across C#, F#, and Visual Basic to reflect current runtime output (including .NET vs .NET Framework differences in some cases).
  • Reformatted a couple of Markdown tables for readability.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
docs/fundamentals/runtime-libraries/system-single.md Updates narrative, links, and tables to align with current snippet output and formatting.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/representation1.vb Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/precisionlist3.vb Switches to interpolated output and updates documented output for .NET vs .NET Framework.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/precisionlist1.vb Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/convert2.vb Updates documented output (including Infinity/NaN section).
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/comparison4.vb Updates snippet region placement and documented output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/comparison2.vb Updates snippet to match current output and documents .NET vs .NET Framework differences.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/vb/PrecisionList4a.vb Adjusts snippet region placement and documents .NET Framework-specific output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/representation1.fs Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/precisionlist4a.fs Documents .NET Framework-specific output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/precisionlist3.fs Updates documented output and runtime notes.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/precisionlist1.fs Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/exceptional1.fs Adds spacing/formatting adjustments and keeps output comments aligned.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/convert2.fs Updates documented output (including Infinity/NaN section).
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/comparison4.fs Formatting cleanup and updated documented output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/comparison2.fs Updates snippet and documented output for .NET vs .NET Framework.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/fsharp/comparison1.fs Minor formatting change.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/representation2.cs Adds spacing/formatting adjustment.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/representation1.cs Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/precisionlist4a.cs Documents .NET Framework-specific output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/precisionlist3.cs Updates documented output for .NET vs .NET Framework.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/precisionlist1.cs Moves snippet region and updates documented output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/exceptional2.cs Moves snippet region and brings documented output into the snippet.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/exceptional1.cs Moves snippet region and brings documented output into the snippet.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/convert2.cs Moves snippet region and updates documented output (including Infinity/NaN section).
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/comparison4.cs Moves snippet region and updates documented output.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/comparison3.cs Moves snippet region and brings documented output into the snippet.
docs/fundamentals/runtime-libraries/snippets/System/Single/Overview/csharp/comparison2.cs Moves snippet region and updates documented output for .NET vs .NET Framework.
docs/fundamentals/runtime-libraries/snippets/System/Double/Overview/vb/precisionlist1.vb Moves snippet region and updates documented output.
docs/fundamentals/runtime-libraries/snippets/System/Double/Overview/fsharp/precisionlist1.fs Updates documented output for current .NET.
docs/fundamentals/runtime-libraries/snippets/System/Double/Overview/csharp/precisionlist1.cs Moves snippet region and updates documented output.

Comment on lines 118 to 78
// Unable to convert ∞ to Int64.
// Unable to convert ∞ to UInt64.
// Unable to convert ∞ to Decimal.
// ∞ (Single) --> ∞ (Double)
//
// -Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64)
// -Infinity (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64)
// Unable to convert -Infinity to Decimal.
// -Infinity (Single) --> -Infinity (Double)
// </Snippet21>
// Unable to convert -∞ to Int64.
// Unable to convert -∞ to UInt64.
// Unable to convert - to Decimal.
// - (Single) --> - (Double)
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The expected output uses the ∞ symbol, but this program prints the value using default formatting (current culture), which commonly yields "Infinity"/"-Infinity". Either force a specific culture/format for printing these values, or change the documented output to match what the code prints under the repo's expected culture.

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +91
' Unable to convert ∞ to Int64.
' Unable to convert ∞ to UInt64.
' Unable to convert ∞ to Decimal.
' ∞ (Single) --> ∞ (Double)
'
' -Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64)
' -Infinity (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64)
' Unable to convert -Infinity to Decimal.
' -Infinity (Single) --> -Infinity (Double)
' Unable to convert -∞ to Int64.
' Unable to convert -∞ to UInt64.
' Unable to convert - to Decimal.
' - (Single) --> - (Double)
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The expected output uses the ∞ symbol, but this program prints the value using default formatting (current culture), which commonly yields "Infinity"/"-Infinity". Either force a specific culture/format for printing these values, or change the documented output to match what the code prints under the repo's expected culture.

Copilot uses AI. Check for mistakes.

The <xref:System.Single> structure does not define any explicit or implicit conversion operators; instead, conversions are implemented by the compiler.

The following table lists the possible conversions of a value of the other primitive numeric types to a <xref:System.Single> value, It also indicates whether the conversion is widening or narrowing and whether the resulting <xref:System.Single> may have less precision than the original value.
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

This sentence has a comma splice and incorrect capitalization ("value, It also..."). Split it into two sentences (or use a semicolon) and use lowercase "it".

Copilot uses AI. Check for mistakes.
:::code language="vb" source="./snippets/System/Single/Overview/vb/comparison1.vb" id="Snippet9":::

Calculated values that follow different code paths and that are manipulated in different ways often prove to be unequal. In the following example, one <xref:System.Single> value is squared, and then the square root is calculated to restore the original value. A second <xref:System.Single> is multiplied by 3.51 and squared before the square root of the result is divided by 3.51 to restore the original value. Although the two values appear to be identical, a call to the <xref:System.Single.Equals%28System.Single%29> method indicates that they are not equal. Using the "G9" standard format string to return a result string that displays all the significant digits of each <xref:System.Single> value shows that the second value is .0000000000001 less than the first.
Calculated values that follow different code paths and that are manipulated in different ways often prove to be unequal. In the following example, one <xref:System.Single> value is squared, and then the square root is calculated to restore the original value. A second <xref:System.Single> is multiplied by 3.51 and squared before the square root of the result is divided by 3.51 to restore the original value. Although the two values appear to be identical, a call to the <xref:System.Single.Equals(System.Single)> method indicates that they are not equal. Using the "G9" standard format string to return a result string that displays all the significant digits of each <xref:System.Single> value shows that the second value is .0000000000001 less than the first.
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

This paragraph says the example uses the "G9" format string to show all significant digits, but the referenced Snippet10 code samples no longer print a G9-formatted line. Update the text to match the snippet output, or re-add the G9 output line to the samples.

Copilot uses AI. Check for mistakes.
if total.Equals result then
printfn "The sum of the values equals the total."
else
printfn "The sum of the values ({total}) does not equal the total ({result})."
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

This printfn call uses a normal string literal, so it will print "{total}" and "{result}" verbatim instead of the variable values. Switch to an interpolated string (or use format specifiers) so the output matches the example output comments below.

Suggested change
printfn "The sum of the values ({total}) does not equal the total ({result})."
printfn $"The sum of the values ({total}) does not equal the total ({result})."

Copilot uses AI. Check for mistakes.
//
// 10.201438 = 10.2014389
// </Snippet10>
printfn $"{value1} = {value2}: {value1.Equals value2}\n"
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

This printfn already appends a newline, and the interpolated string also includes a trailing "\n", which will produce an extra blank line that isn't reflected in the documented output. Remove the embedded newline (or update the expected output accordingly).

Suggested change
printfn $"{value1} = {value2}: {value1.Equals value2}\n"
printfn $"{value1} = {value2}: {value1.Equals value2}"

Copilot uses AI. Check for mistakes.
// 1 = 1.0000001: False
// 1 is approximately equal to 1.0000001: True
// -1 = -1.0000001: False
// -1 is approximately equal to - 1.0000001: True
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The documented output has an extra space after the minus sign ("- 1.0000001"), but the code will print "-1.0000001". Update the output comment so it matches the actual formatted output.

Suggested change
// -1 is approximately equal to - 1.0000001: True
// -1 is approximately equal to -1.0000001: True

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +95
// Unable to convert ∞ to Int64.
// Unable to convert ∞ to UInt64.
// Unable to convert ∞ to Decimal.
// ∞ (Single) --> ∞ (Double)
//
// Unable to convert -∞ to Int64.
// Unable to convert -∞ to UInt64.
// Unable to convert -∞ to Decimal.
// -∞ (Single) --> -∞ (Double)
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The expected output uses the ∞ symbol, but this program prints the value using default formatting (current culture), which commonly yields "Infinity"/"-Infinity". Either force a specific culture/format for printing these values, or change the documented output to match what the code prints under the repo's expected culture.

Suggested change
// Unable to convert to Int64.
// Unable to convert to UInt64.
// Unable to convert to Decimal.
// (Single) --> (Double)
//
// Unable to convert - to Int64.
// Unable to convert - to UInt64.
// Unable to convert - to Decimal.
// - (Single) --> - (Double)
// Unable to convert Infinity to Int64.
// Unable to convert Infinity to UInt64.
// Unable to convert Infinity to Decimal.
// Infinity (Single) --> Infinity (Double)
//
// Unable to convert -Infinity to Int64.
// Unable to convert -Infinity to UInt64.
// Unable to convert -Infinity to Decimal.
// -Infinity (Single) --> -Infinity (Double)

Copilot uses AI. Check for mistakes.
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.

[UUF] Code examples don't match text

1 participant