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

Task: Implement ISpanFormattable on atomic types #125

Open
NightOwl888 opened this issue Dec 14, 2024 · 0 comments
Open

Task: Implement ISpanFormattable on atomic types #125

NightOwl888 opened this issue Dec 14, 2024 · 0 comments
Labels
design good first issue Good for newcomers pri:normal up for grabs This issue is open to be worked on by anyone
Milestone

Comments

@NightOwl888
Copy link
Owner

ISpanFormattable is implemented in Number with a substandard implementation. However, none of the atomic types are overriding it to provide an optimized implementation (which we already have implemented in DotNetNumber). So, we just need to add these overrides to significantly improve performance on these methods.

public override bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)
{
    return DotNetNumber.TryFormatInt64(Value, format, provider, destination, out charsWritten);
}

Unlike the types in J2N.Numerics, there is no reason to provide a static overload. This is just a convenience to format the value without first converting it to a .NET numeric type.

We will also need documentation. In general, the documentation can be copied from the TryFormat method in the corresponding type in J2N.Numerics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design good first issue Good for newcomers pri:normal up for grabs This issue is open to be worked on by anyone
Projects
None yet
Development

No branches or pull requests

1 participant