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

Support for long, float and other numeric types #38

Open
clement911 opened this issue Jun 20, 2023 · 0 comments
Open

Support for long, float and other numeric types #38

clement911 opened this issue Jun 20, 2023 · 0 comments

Comments

@clement911
Copy link

clement911 commented Jun 20, 2023

Formatting numbers only works with double, int and short.
Other numeric types should be supported, such as byte, sbyte, ushort, uint, long, ulong, float, decimal.

  var format = new NumberFormat("#,##0");

  format.Format(1234, CultureInfo.InvariantCulture);//1,234 => OK
  format.Format(1234d, CultureInfo.InvariantCulture);//1,234 => OK
  format.Format(1234f, CultureInfo.InvariantCulture);//1234 => Fail
  format.Format(1234L, CultureInfo.InvariantCulture);//1234 => Fail
  format.Format(1234m, CultureInfo.InvariantCulture);//1234 => Fail
  format.Format((ushort)1234, CultureInfo.InvariantCulture);//1234 => Fail

I believe it's because the evaluator only checks for double, int and short.
I might be more appropriate to try casting to IConvertible and use IConvertible.ToDouble.

Similarly it would be nice to support System.DateOnly and System.TimeOnly

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

1 participant