Skip to content

[release/11.0] Correct decimal conversions to Half and BFloat16 - #135730

Merged
tannergooding merged 1 commit into
dotnet:release/11.0from
tannergooding:tannergooding-backport-pr-135668-release-11-0
Oct 15, 2026
Merged

tannergooding merged 1 commit into
dotnet:release/11.0from
tannergooding:tannergooding-backport-pr-135668-release-11-0

Conversation

@tannergooding

@tannergooding tannergooding commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes Issue #135659

main PR #135668

Description

This backports the fix for double-rounding in decimal-to-Half and decimal-to-BFloat16 conversions. The exact fallback now rounds directly to the destination format, and Half parsing uses the corrected tie-to-even exponent boundary.

Customer Impact

Applications converting decimal values close to Half or BFloat16 midpoints can receive the adjacent representable value on the wrong side of the midpoint. The error also affects some Half subnormal values.

Regression

No. The issue reproduces in .NET 11 RC builds; Half had the same double-rounding issue in .NET 10, and BFloat16 is new in .NET 11.

Testing

  • .\build.cmd clr+libs -rc checked — passed (checked baseline).
  • .\build.cmd clr.corelib+clr.nativecorelib+libs.pretest -rc checked — passed, 0 warnings and 0 errors.
  • dotnet build /t:test src\libraries\System.Runtime\tests\System.Runtime.Tests\System.Runtime.Tests.csproj — passed: 77,859 total, 0 failed, 87 skipped.

Risk

Low. The change is limited to decimal floating-point rounding and Half's parser tie boundary, with regression cases for midpoint-adjacent values, ties, and subnormals. The mainline PR's focused comparison reported 6.368 ns for a BFloat16 decimal cast versus 4.096 ns for casting through double; the run had notable variance and was not a separate baseline-runtime build, so this is an observed cost rather than conclusive regression evidence. No separate release-branch benchmark was run.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Resolves #135659

Note

This PR description was prepared with GitHub Copilot.

Use target-format fast paths and exact fallback rounding to avoid double-rounding.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 8e8152d)
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

@jeffhandley jeffhandley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I support backporting this for .NET 11 GA for sake of correctness involving APIs that are new in .NET 11.

@ViveliDuCh

Copy link
Copy Markdown
Member

Hi,

the code complete date for GA is Monday 19th October. Make sure to merge this PR on that date at the latest, or it won't make it into that release.

As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval).

Happy to help with the merge if needed!

@tannergooding
tannergooding requested a review from artl93 October 15, 2026 00:00
@tannergooding tannergooding added the Servicing-consider Issue for next servicing release review label Oct 15, 2026
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 15, 2026
@rbhanda rbhanda added this to the 11.0.0 milestone Oct 15, 2026
@tannergooding

Copy link
Copy Markdown
Member Author

/ba-g unrelated known test failures

@tannergooding
tannergooding merged commit fa9c9f3 into dotnet:release/11.0 Oct 15, 2026
152 of 159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Numerics Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants