Double Versus Decimal in C#

Double is useful for scientific computations (such as computing spatial coordinates). Decimal is useful for financial computations and values that are “man-made” rather than the result of real-world measurements. Here’s a summary of the differences.
  

Category Double Decimal
Internal Representation Base 2  Base 10
Decimal Precision 15-16 Significant Figures 28-29 Significant figures
Range ±(~10−324 to ~10308)  ±(~10−28 to ~1028) 
Special Values +0, −0, +∞, −∞, and NaN None 
Speed Native to processor  Non-native to processor
(about 10 times slower than double)

Most business applications should probably be using decimal rather than float or double. Our thumb rule should be manmade values such as currency are usually better represented with decimal floating point.
 
Hope this helps.
 

Happy Coding
Gopinath

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s