Skip to content

Cleanup some math helpers in DecimalCalc#76118

Closed
huoyaoyuan wants to merge 2 commits intodotnet:mainfrom
huoyaoyuan:decimal-math-helper
Closed

Cleanup some math helpers in DecimalCalc#76118
huoyaoyuan wants to merge 2 commits intodotnet:mainfrom
huoyaoyuan:decimal-math-helper

Conversation

@huoyaoyuan
Copy link
Copy Markdown
Member

BigMul(uint) and DivRem are not included.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Sep 24, 2022
@ghost
Copy link
Copy Markdown

ghost commented Sep 24, 2022

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link
Copy Markdown

ghost commented Sep 24, 2022

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

Issue Details

BigMul(uint) and DivRem are not included.

Author: huoyaoyuan
Assignees: -
Labels:

area-System.Numerics, community-contribution

Milestone: -

//
const uint SNGBIAS = 126;
int exp = (int)(GetExponent(input) - SNGBIAS);
int exp = input.Exponent + 1;
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.

The change is correct in that it matches current behavior, but there isn't anything explaining why its "off by one".

That is Single.Exponent and Double.Exponent return the exact and correct exponent, while this is the adjusting it to be one higher than expected. I've not sat down to work through "why" the adjustment is needed for decimal's scale but this is the type of scenario where there should really be a comment explaining it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The logic looks slightly different for float. The original code lacks &mask, I'm not sure if the failure is related since VS debugging is somehow broken for me. But I don't expect the logic of float to be different from double.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These helpers should be fixed once this PR gets merged. We tabled it for .NET 7 but now that we are starting to work on .NET 8 it should be revisited.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks. Then I think it's better to wait for that PR.

@tannergooding
Copy link
Copy Markdown
Member

Looks like there are some test failures that need to be looked into

@huoyaoyuan huoyaoyuan marked this pull request as draft September 27, 2022 07:16
@ghost ghost closed this Oct 27, 2022
@ghost
Copy link
Copy Markdown

ghost commented Oct 27, 2022

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 2022
@huoyaoyuan huoyaoyuan deleted the decimal-math-helper branch May 16, 2023 19:04
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Numerics community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants