fix: Don't cast numeric types via boxing

This is illegal
This commit is contained in:
John Colvin committed 2022-05-02 12:29:01 -04:00
1 parent 195c24ffef
commit af816bb905
1 file changed
+2 -2
+2 -2
View File
@@ -218,8 +218,8 @@ namespace bts.utils {
public static decimal round_to_decimal<T>(T value, int decimals = API_DECIMAL_PRECISION)
where T : IFloatingPoint<T> =>
T.IsNaN(value) ? 0 :
// TODO: avoid boxing/unboxing
(decimal)(object)T.Round(value, decimals, MidpointRounding.AwayFromZero);
NumericCastInConverter<T>.to_decimal(
T.Round(value, decimals, MidpointRounding.AwayFromZero));
public static bool is_int<T>(T value) where T : IFloatingPoint<T> =>
epsilon_equals(value, T.Round(value));