Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-02-2009
Member
 
Join Date: Jan 2009
Posts: 36
DataType Decimal or double for Currency?

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?
Reply With Quote
  #2  
Old 14-02-2009
Member
 
Join Date: Jan 2009
Posts: 9
Re: DataType Decimal or double for Currency?

I always use Decimal when I need to do anything with decimals, especially currency. This was told to us by our .net professor!
Reply With Quote
  #3  
Old 14-02-2009
Member
 
Join Date: Jan 2009
Posts: 19
Re: DataType Decimal or double for Currency?

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)
Reply With Quote
  #4  
Old 14-02-2009
Member
 
Join Date: Aug 2008
Posts: 145
Re: DataType Decimal or double for Currency?

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.
Reply With Quote
  #5  
Old 14-02-2009
Member
 
Join Date: Jan 2009
Posts: 18
Re: DataType Decimal or double for Currency?

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!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "DataType Decimal or double for Currency?"
Thread Thread Starter Forum Replies Last Post
Pirates of Black Cove, no missions after ?Double-Double Crossing? Maee Video Games 7 28-12-2011 05:18 PM
Changing the entity of a datatype GOOL Software Development 6 06-01-2011 08:31 AM
Change double datatype in parameter ISAIAH Software Development 5 08-03-2010 09:24 AM
Reducing Double to 2 Decimal Places Level8 Software Development 5 09-02-2010 09:00 PM
C# timestamp datatype Mehraj Software Development 3 04-08-2009 06:58 PM


All times are GMT +5.5. The time now is 10:18 PM.