c# - Decimal vs. Double for small currency numbers that only get stored, not manipulated -


i'm writing small application accesses sql database retrieve information local events, including prices, , allows creation , editing of new events exporting formatted , filtered lists of events printing etc.

now event may have entrance fee represented in data sets (ms sql server data type "money"), i'm wondering data type use in client application.

i know should use decimal currency calculations because of high precision - i'm not going any calculations, entered number 2 decimal places , stored database, , later gets loaded again , displayed or exported printable document - no calculations accumulate inaccuracies.

so data type use in case? still go decimal because it's money , don't care memory etc? or use double instead precise enough? alternatively store price in cents integer well. type should go for?

generally when dealing existing data source, follow what's used. in case, sql server .net reader maps money decimal. means no awkward casting , nothing wasted in transmission.

tomtom's answer in comment point case when double can performance needed acceptable precision, unless you're dealing millions of calculations or starved in storage there's no reason not use decimal financial data.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -