Solved

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

Posted on 2010-08-16
3
903 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
[X]
Welcome to Experts Exchange

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
 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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