Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Become a Premium Member and unlock a new, free course in leading technologies each month.

Solved

Posted on 2010-08-16

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"

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"

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

- Help others & share knowledge
- Earn cash & points
- Learn & ask questions

3 Comments

http://visualbasic.about.com/od/usingvbnet/a/decdatatype.htm

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.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Earn Certification

HTML5 Specialist - Certification

Free withPremium

Course of the Month7 days, 2 hours left to enroll

Join the community of 500,000 technology professionals and ask your questions.