I have a Money Type that allows math operations and is sensitive to exchange rates so it will reduce one currency to another if rate is available to calculate in a given currency, rounds by various methods. It has other features that are sensitive to money, but I need to ask if the basic data type used should be made generic in nature.
I've realized that the basic data type to hold an amount may differ for financial situations, for example:
- retail money might be expressed as all cents using
int
orlong
where fractions of cents do not matter, decimal
is commonly used for its fixed behaviour,- sometimes
double
is used for finance and large values - sometimes a special BigInteger or 3rd-party type is used.
I want to know if it would be considered good form to turn Money
into Money<TAmount>
and where TAmount: struct
so it can be used in any one of the above chosen scenarios?
TAmount would represent the basic amount value and be any of the types mentioned above or others.