Solved

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

Posted on 2010-08-16
3
870 Views
Last Modified: 2012-05-10
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"
0
Comment
Question by:ipjyo
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 250 total points
ID: 33449197
Decimal would be more appropriate

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.
0
 
LVL 11

Assisted Solution

by:ladarling
ladarling earned 250 total points
ID: 33449257
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.
0
 

Author Comment

by:ipjyo
ID: 33449585
Thanks for the clarification.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 members asked questions and received personalized solutions in the past 7 days.

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

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now