Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-16
3
Medium Priority
?
921 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 1000 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 1000 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

661 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