What is Difference Between Double and Decimal in C#?

PropertyDoubleDecimal
Memory StorageDouble is stored in  memory in binary form , which means that it can accurately display only those numbers that are a power of 2. Otherwise, decimal rounding errors occur.Decimal is stored in  memory in decimal form , so it can display fractional parts of a number with absolute precision.
When to use?Decimal is needed where the fractional part is important. For example, when working with  finance .For values that are more artifacts of nature that can’t really be measured exactly anyway, float are more appropriate. For example,  scientific data  would usually be represented in this form.
Memory Occupieddouble memorydouble memorydecimal memorydecimal memory
Fractional Precision15-16 places28-29 places
Special Values+0, -0,+ ∞- ∞, NaN
AdditionalyDouble is a native type for the processor, so operations with this type are much faster.

Leave a Comment