Hello friends!
I have a simple question about data type for money
Which is a better practice to use decimal or double for currency or money?
What you guys say?
Hello friends!
I have a simple question about data type for money
Which is a better practice to use decimal or double for currency or money?
What you guys say?
I always use Decimal when I need to do anything with decimals, especially currency. This was told to us by our .net professor!
In general discussion about decimal & double.
If it is "scientific" measurement (I mean weight, length, area etc) use double.
If it is financial, or has anything to do with law (e.g. the area of a property) then use decimal.
The hard part is rounding.
If the tax is 2.4% do you round in the details or after the sum?
Most of the time yo have to do both (AND fix the difs)
Money should be a money type assuming that everything is going to be either in whole cents or (like gasoline) in whole mils (tenths of a cent)
Quantity is tricky.
4.5 L... is it always going to be a whole number of mL? If so, a decimal type with three decimal places would be a good choice, or just use int and store mL internally.
Please have a look at this
http://www.yoda.arachsys.com/csharp/decimal.html
here you will find the exact importance of using decimal over double for currency or money!
Bookmarks