-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[API Proposal]: Add Support for ToBase In BigInteger Parsing #84684
Comments
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsBackground and motivationGiven a string, the current implementation of API Proposal// Add Support For String and/or ReadOnlySpan<char>
public static BigInteger Parse(string value, int tobase);
public static BigInteger Parse(ReadOnlySpan<char> value, int tobase);
public static bool TryParse(string value, int tobase, out BigInteger result);
public static bool TryParse(ReadOnlySpan<char> value, int tobase, out BigInteger result); API Usage// Given a couple of strings; assumption: large strings
string binary = "101010101100";
string hex = "0x34";
ReadOnlySpan<char> binarySpan = binary.AsSpan();
ReadOnlySpan<char> hexSpan = hex.AsSpan();
BigInteger bigIntA = BigInteger.Parse(binary, 2);
BigInteger bigIntA2 = BigInteger.Parse(binarySpan, 2);
_ = BigInteger.TryParse(hex, 16, out BigInteger bigIntOut)
_ = BigInteger.TryParse(hexSpan, 16, out BigInteger bigIntOut2)
// etc. Alternative DesignsNo response RisksNo response
|
An additional consideration is to add |
For
|
Background and motivation
Given a string, the current implementation of
BigInteger.Parse
andBigInteger.TryParse
lacks support for ToBase i.e.; 2, 8, 10, 16API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: