What is the difference between System.Single, System.Double, and System.Decimal datatypes?

Hi,

Anybody know the differences between these datatypes? what should i use for multiplication and division of decimal numbers?

thanks!
0
ido
11/14/2005 6:24:50 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

2 Replies
995 Views

Similar Articles

[PageSpeed] 48

The difference between Single and Double is how large of a number they can hold.
A variable defined as Single can hold a number as large as 3.402823e38.  Such a variable consumes 32 bits of system memory.
A variable defined as Double can hold a number as large as 1.79769313486232e308.  Such a variable consumes 64 bits of system memory.
A Decimal consumes 96 bits of system memory and is best when you need an unusually large number of decimal places to be calculated accurately with little rounding.  It can hold a number as large as 79,228,162,514,264,337,593,543,950,335.
If you don't need any decimal places at all then you should generally use an Integer.


Here's more info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconthenetframeworkclasslibrary.asp

You should generally be able to do standard mathematical equations with all these variable types.

I hope this helps,
Steve C. Orr,
MCSD, MVP in ASP.NET
http://SteveOrr.net


I hope this helps,

Steve C. Orr,

http://SteveOrr.net
0
Steve
11/14/2005 8:07:14 PM

This is the difference between the datatypes, or just type the data type in the dynamic help in VS.NET

Single
variables are stored as signed IEEE 32-bit (4-byte) single-precision floating-point numbers ranging in value from -3.4028235E+38 through -1.401298E-45 for negative values and from 1.401298E-45 through 3.4028235E+38 for positive values. Single-precision numbers store an approximation of a real number.

Double
variables are stored as signed IEEE 64-bit (8-byte) double-precision floating-point numbers ranging in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values.

Decimal variables are stored as signed 128-bit (16-byte) integers scaled by a variable power of 10. The scaling factor specifies the number of digits to the right of the decimal point; it ranges from 0 through 28. With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With 28 decimal places, the largest value is +/-7.9228162514264337593543950335, and the smallest nonzero value is +/-0.0000000000000000000000000001 (+/-1E-28).

Appending the literal type character D to a literal forces it to the Decimal data type. Appending the identifier type character @ to any identifier forces it to Decimal. You might need to use the D type character to assign a large value to a Decimal variable or constant, as the following example shows:

Dim BigDec1 As Decimal = 9223372036854775807   ' No overflow.
Dim BigDec2 As Decimal = 9223372036854775808   ' Overflow.
Dim BigDec3 As Decimal = 9223372036854775808D  ' No overflow.


 


Seven Days Without Laughter Makes One Weak
0
maelstorm1983
11/14/2005 8:20:32 PM
Reply:

Similar Artilces:

What is the difference between System.Single, System.Double, and System.Decimal datatypes? #2
Which of the datatypes should I use for regular decimal multiplication and division??? I don't understand the differences between the datatypes.Does anyone know the difference? Thanks!! Here is a good comparison. This should help you out:http://www.informit.com/guides/content.asp?g=dotnet&seqNum=119&rl=1All I know is that I don't know nothin!ApplicationDeveloper The link just tells you the differences but those data types System.Double and System.Single are seldom used for multiplication and division because you can use Decimal data type where you can set precision and s...

Difference from System.Web and System.Net
Excuse me, could anyone explain me a concept of the differnce between System.Web and System.Net? And how to use two of these? Thank you, Aom I believe you are on the wrong mailing list! On 2014-06-26, 5:49 AM, Alonze wrote: > Excuse me, could anyone explain me a concept of the differnce between System.Web and System.Net? > And how to use two of these? > > > Thank you, > > Aom > > > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-...

difference between System.Web.Mail and System.Net.Mail
What is difference between System.Web.Mail and System.Net.Mail  namespace?What is use of both ? System.Web.Mail was in .NET Framework v1.1System.Net.Mail is in .NET Framework v2.0 and greaterSame use, although there is more functionality in System.Net.Mail since it is a later version of the framework. Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!  What All-Star said. I assume the reason it was moved to a different namespace is because the internet is actually a suite of technologies: e-mail, ftp, http (web), etc. E-mail and...

CLR.NET datatype for decimal is System.String or Decimal
CLR.NET datatype for decimal is System.String or System.Decimal the documentation says System.string while it is mapped to DbType.decimal I need some understanding on this. any help thanks vsv ...

Problem with difference between System.Web.Mail and System.Net.Mail in using attachments
I have a web .Net app which sends emails with attachments.  After the email is sent I clean up aftermyself and delete the attachments from disk.   In upgrading to .Net 2  I changed the email logic from using system.web.mail to system.net.mail  (of course vs is telling me system.web.mail is obsolete).In .Net 1.1,  the files deleted with no problem but in .Net 2 when I attempt to delete  I receive The process cannot access the file ...' because it is being used by another process. If I change the code back to using system.web.mail I can delete the file...

What additional advantage we get through System.net.mail over the old system.web.mail?
What additional advantage we get through System.net.mail over the old system.web.mail?Is it needed to configure the smtp server? Plz tell me the steps to develop the email sending facility in our applicationSwati Jain Take a look at www.systemnetmail.com.JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue....

System.web.mail to System.net.mail
I converted a asp.net web app from VS 2003 to VS 2005. i now get error message when i build it  stating system.web.mail  is obsolute,  use system.net.mail i redefine to system.net.mail but now i get other error message such as smtpMail does not exist in the current context. cannot implicitly convert type string to System.Net.Mail.MailAddress   so System.Web.Mail want work in ASP.net web app convert to VS 2005 running on framework 2.0?           because if i change to System.Net.Mail  i am ...

moving from multidisk system to single disk system
I have several disks that I've accumulated (for space) on my system, and would like to consolidate these to a single large hard drive. My plan is the use PING or Clonezilla to clone my largest (main 500GB) hard drive to a 1 - 2 TB hard drive, and I think these can also move the other partitions sdbX, sdcX and sddX to the same hard drive, but I have to tell the system I did this or it won't boot. AFAIK: I need to do this in fstab, but where else? Also, since the "new" drivers use the disk SN/ID, how to deal? THANKS!!!!!!!!!!!! Patti BTW: The reasoning i...

What is different between System.Type and System.Data.DBType?
I have a question. I want to compare if a parameter is specific datatype. My code like:private function Fun1 (byval sType as System.Type) as stringIf sType = System.String Then      Return Convert.ToString(ro)else    .....End ifThe error msg I got:"String is a type in system. and cannot be used as expression"What should I do? Thanks, Try either:If sType = GetType(System.String)or:If sType Is GetType(System.String)(I can't remember offhand which one it's supposed to be).Hope that helps!Marciehttp://www.datagridgirl.comNEW! http://www.gridviewgirl.com...

Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, System.Type, System.String, System.String, Boolean)'.
  I have a website which is running on IIS 5.1. Wen ever I am trying to access any page based on .net framework 2.0 I get this error Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, ...

i ve got System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, failed. exception
hi everyone i created windows form user control and i embedded it to asp.net web for , my user control sends mail using by System.Net.Mail library but when i open my web site and click to send button that on my user control  i ve got this exception System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.    what can i do ? my best regards ..    Couple of questions: 1) Are you running this from an IIS installati...

'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'
It code worked fine on my PC..but gettting following message on server.... 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'  i checked this thread http://forums.asp.net/p/1123792/1869084.aspx#1869084  but it doesn't help me...  My Blog"Don't be afraid to be wrong; otherwise you'll never be right." Updating global assembly cache of server, solved this error Some how installation is not updating GAC..so you have to do it manuallyMy Blog"Don't be afraid to be wrong; otherwis...

ANN: Single File System v.2.70: delphi virtual single-file system
AidAim Software is pleased to announce Single File System v.2.70, a virual file system for Delphi / C++ Builder within the single OS file. New features were added. Some bugs have been fixed. You can read details about the changes being made on our site: http://www.aidaim.com/info/news.php Single File System (SFS) provides an easy way to work with multiple files and folders stored as a part of a single file using advanced compression and encryption functionality. This solution encapsulates small but powerful file system within a single file. The mechanism of SFS includes some a...

ANN: Single File System v.2.70: delphi virtual single-file system
AidAim Software is pleased to announce Single File System v.2.70, a virual file system for Delphi / C++ Builder within the single OS file. New features were added. Some bugs have been fixed. You can read details about the changes being made on our site: http://www.aidaim.com/info/news.php Single File System (SFS) provides an easy way to work with multiple files and folders stored as a part of a single file using advanced compression and encryption functionality. This solution encapsulates small but powerful file system within a single file. The mechanism of SFS includes some...

Web resources about - What is the difference between System.Single, System.Double, and System.Decimal datatypes? - asp.net.getting-started

Difference - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

3Q EARNINGS: Mark Zuckerberg on the Differences Between Messenger and WhatsApp
When Facebook announced its intent to acquire cross-platform messaging application WhatsApp in February, questions surfaced on whether WhatsApp ...

Facebook Tips: What’s the Difference between Top News and Most Recent?
The following is part of our series, Facebook Tips, which answers some of the most commonly asked questions about using Facebook. While we hope ...

World powers adopt UN Syria resolution to end civil war, but differences on Assad's future as leader ...
The UN Security Council unanimously adopts a resolution endorsing a peace process to end the Syrian war.


What’s the Difference Between Gen Y and Gen Z?
... in relation to purchasing habits, top brands, or preferred networks, download the report and check out the infographic below for key differences ...

Differences Matter
I was struck by this paragraph in the Slate piece on our portfolio company YouNow this weekend: In theory, YouNow sounds a bit like Twitter’s ...

There will be one huge difference when you see the new ‘Star Wars’ movie in theaters
When you head out to see "Star Wars: The Force Awakens," the film will have one very big change as soon as the movie starts. Up until now, each ...

Harrison Ford Mocks Trump: You Can’t Tell The Difference Between Movies And Real Life
Harrison Ford Mocks Trump: You Can’t Tell The Difference Between Movies And Real Life

Can you spot the differences between fact-checking a GOP debate and whack-a-mole?
It shouldn’t come as any big surprise that Tuesday night’s Republican presidential debate was a bonanza for fact-checkers. Here are a few of ...

Resources last updated: 12/20/2015 7:22:23 PM