문제

I'm creating a numeric type called BigNum which is meant to be a really expandable BCD. In the process, I'm overloading most/all of the normal numeric operators. My main question is, do I need to overload each operator for each built-in numeric type (long, ulong, int, uint, short, ushort, byte, sbyte, float, double, decimal), or can I just overload it for double/decimal and have the system coerce the other types behind the scenes?

Edit: I'm also wondering if having the system coerce to double (if indeed this is viable) will maintain accuracy with whole numbers.

도움이 되었습니까?

해결책

You should provide overloads for all the types you intend to support to avoid unnecessary conversions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top