c# variable types for financial data

I currently have a ton of numbers in my classes that are either doubles of floats.  I am going to standardize and make them consistent.  I really just need two decimal places and I hate the extra decimal places these variables have.  What kind of variable should I use?  I really just need the 2 decimals.

Thanks
jackjohnson44Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RouchieCommented:
I believe the System.Decimal type is the one you need, however, if you are only using two decimal places then double will suffice.  Be aware however, that when rounding to two decimal places, you risk 'losing' a lot of money!

Its often best to display long decimals to two decimal places like this, which retains the original value:

myDecimal.ToString("0.##")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
I agree (partially) with the above:  decimal has greater precision than double does, and it should be used whenever you are performing financial calculations.
0
Asim NazirCommented:
Hi,

For financials, Decimal is used as the most suitable data type and we normally store data with more than 2 decimal places but off-course we can show it to user with just two decimal places.

So, for display purpose, you can just format data to two decimal places following:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/e697f2d1-5471-4e6b-8854-658c305ff024/convert-double-to-2-decimal-places
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.