# What is the difference between Vb.Net decimal and double datatypes?

hi,

Which data type I should use to compare two numeric string values?
I have the below two strings. I need to convert them to decimal/double and find the difference.
Which datatype is more appropriate for this data? Thank you.

dim str1 as string = "5.41245"
dim str2 as string = "4.31245"
###### 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.

Commented:
Decimal would be more appropriate

http://dotnetkicks.com/csharp/NET_Decimal_vs_float_double_What_s_the_Difference

In short, decimal stores the data exactly up to a certain number of places, whereas doubles store it in binary form as close as a binary can get to the real number.

Experts Exchange Solution brought to you by

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

Commented:
Single (32 Bit floating point) would be best in this case, actually.
Double is a 64 bit floating point structure, suitible for very large floating point values.
Decimal (128 bit) is not actually a floating point structure:
http://msdn.microsoft.com/en-us/library/ae55hdtk(VS.80).aspx
Quote:

The nonintegral numeric data types are Decimal (128-bit fixed point), Single Data Type (Visual Basic) (32-bit floating point), and Double Data Type (Visual Basic) (64-bit floating point). They are all signed types. If a variable can contain a fraction, declare it as one of these types.

Decimal is not a floating-point data type. Decimal numbers have a binary integer value and an integer scaling factor that specifies what portion of the value is a decimal fraction.
Author Commented:
Thanks for the clarification.
###### 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
Visual Basic.NET

From novice to tech pro — start learning today.