This repository was archived by the owner on Jan 23, 2023. It is now read-only.
[release/3.0] Updating Math.Round and MathF.Round to be IEEE compliant so that the intrinsic and managed form are deterministic.#26017
Merged
Conversation
…intrinsic and managed form are deterministic. (#25901) * Updating Math.Round and MathF.Round to be IEEE compliant so that the intrinsic and managed form are deterministic. * Fixing the Math.Round and MathF.Round handling for values greater than 0.5 and less than 1.0 * Applying formatting patch.
Member
Author
|
This is a backport of #25901 |
Member
Author
|
CC. @CarolEidt, @AndyAyersMS, @jkotas, @danmosemsft I added one additional commit, which addresses @CarolEidt's request that we document that only the |
AndyAyersMS
approved these changes
Aug 5, 2019
Member
|
Bug exposed by enabling tiering by default in 3.0 |
Member
Member
|
Branch is open, merging |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
The managed implementations of the Math.Round functions were not IEEE compliant and would return a different result between Debug and Release mode. In .NET Core 3 with the tiered JIT support they now return a different result for the first 29 calls of the function before the JIT recognizes them as "hot" and they are rejitted.
Customer Impact
Customers calling
Math.RoundorMathF.Roundmay get different behavior between two consecutive calls to the functions.Regression?
Yes, as per the description.
Risk
Low. This is pulling in a port of a known good implementation from the BSD SoftFloat library. It was additionally validated that all 4 billion inputs for the single-precision input range are returning the correct values as compared to the intrinsic forms of these APIs (which compile down to the
roundssandroundsdinstructions).