-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
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 => FailI 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
Metadata
Metadata
Assignees
Labels
No labels