Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify formatting part of BigInteger of CoreLib #97889

Merged
merged 14 commits into from
Mar 22, 2024

Conversation

huoyaoyuan
Copy link
Member

Another part of #28657, in continuation of #85978 and #95402.

It's 2.5 years from my initial attempt on this, and more than half a year for code in this PR.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Feb 2, 2024
@ghost
Copy link

ghost commented Feb 2, 2024

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

Issue Details

Another part of #28657, in continuation of #85978 and #95402.

It's 2.5 years from my initial attempt on this, and more than half a year for code in this PR.

Author: huoyaoyuan
Assignees: -
Labels:

area-System.Numerics, community-contribution

Milestone: -

@tannergooding
Copy link
Member

It's 2.5 years from my initial attempt on this, and more than half a year for code in this PR.

Thanks for continuing the work/effort here! I'll try to get this reviewed in the next week or so, but as you know there's a few different BigInteger PRs still pending going in, so we'll see where it ends up.

@huoyaoyuan
Copy link
Member Author

huoyaoyuan commented Feb 3, 2024

Splitting optimization to another PR to make this easier. I don't want this to be blocked (and blocking for others) for longer period.

Edit: I'm probably unable to complete this before vacation.


internal static unsafe void NumberToString<TChar>(ref ValueListBuilder<TChar> vlb, ref NumberBuffer number, char format, int nMaxDigits, NumberFormatInfo info) where TChar : unmanaged, IUtfChar<TChar>
{
Debug.Assert(typeof(TChar) == typeof(char) || typeof(TChar) == typeof(byte));
Copy link
Member Author

Choose a reason for hiding this comment

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

This assert is painful for polyfill. How about switching to sizeof?
IBinaryInteger provides similar performance with IUtfChar on CLR, but on mono it may cause regression.

Copy link
Member

Choose a reason for hiding this comment

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

How is it painful, I'm not understanding?

Copy link
Member Author

Choose a reason for hiding this comment

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

S.R.Numerics can't call these methods with byte or char directly, but a polyfill type that implements an internal definition of IUtfChar instead. I have done this in previous PR. There's no such type check in parsing logic.

@huoyaoyuan
Copy link
Member Author

Tests are passing locally. The adapting of this PR is unoptimized to simplify the reviewing.

@tannergooding
Copy link
Member

@huoyaoyuan, there's a conflict here. This otherwise looks good to me so I'll finish my last pass and merge if CI passes after the conflict is resolved

@huoyaoyuan
Copy link
Member Author

Conflicts resolved.

@tannergooding tannergooding merged commit 80d37dd into dotnet:main Mar 22, 2024
148 of 150 checks passed
@huoyaoyuan huoyaoyuan deleted the numerics-format-2 branch March 23, 2024 04:55
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2024
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.

2 participants