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

Add implementation for ISpanFormattable #10

Open
vyacheslav-volkov opened this issue Dec 7, 2023 · 2 comments
Open

Add implementation for ISpanFormattable #10

vyacheslav-volkov opened this issue Dec 7, 2023 · 2 comments

Comments

@vyacheslav-volkov
Copy link

First of all thanks for this project, the best implementation on the market.
I think it would be a good idea to implement the ISpanFormattable interface, this will reduce allocations in some cases.

@vyacheslav-volkov
Copy link
Author

Also you can optimize this code if BigDecimal implements ISpanFormattable:

 return float.Parse(value.ToString(ToDecimalOrFloatFormat), ToDecimalOrFloatStyle, CultureInfo.InvariantCulture);
 return double.Parse(value.ToString(ToDecimalOrFloatFormat), ToDecimalOrFloatStyle, CultureInfo.InvariantCulture);
 ...

@mikernet
Copy link
Member

mikernet commented Dec 7, 2023

Yeah, this would definitely be useful, but the string formatting would need a bit of a complex refactoring to support that so I haven't had time to do it. The string formatting is all a bit obtuse right now, mostly because the runtime BCL hides a lot of the functionality needed to implement it easily for a custom numeric type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants