Difference between Decimal, Float and Double in .Net

18 Jun, 2021
Float : It is a floating binary point type variable. Which means it represents a number in it’s binary form. Float is a single precision 32 bits(6-9 significant figures) data type. It is used mostly in graphic libraries because of very high demand for processing power, and also in conditions where rounding errors are not very important.
Double : It is also a floating binary point type variable with double precision and 64 bits size(15-17 significant figures). Double are probably the most generally used data type for real values, except for financial applications and places where high accuracy is desired.
Decimal : It is a floating decimal point type variable. Which means it represents a number using decimal numbers (0-9). It uses 128 bits(28-29 significant figures) for storing and representing data. Therefore, it has more precision than float and double. They are mostly used in financial applications because of their high precision and easy to avoid rounding errors.
Example – 
C#
using System;  public class GFG {      static public void Main()    {          double d = 0.42e2;    //double data type        Console.WriteLine(d); // output 42          float f = 134.45E-2f;  //float data type        Console.WriteLine(f); // output: 1.3445          decimal m = 1.5E6m;   //decimal data type        Console.WriteLine(m); // output: 1500000    }}
Output –
Example of double, float and decimal
Comparison between Float, Double and Decimal on the Basis of : 
No. of Bits used –
Float uses 32 bits to represent data.Double uses 64 bits to represent data.Decimal uses 128 bits to represent data.
Float uses 32 bits to represent data.
Double uses 64 bits to represent data.
Decimal uses 128 bits to represent data.
Range of values –
The float value ranges from approximately ±1.5e-45 to ±3.4e38.The double value ranges from approximately ±5.0e-324 to ±1.7e308.The Decimal value ranges from approximately ±1.0e-28 to ±7.9e28.
The float value ranges from approximately ±1.5e-45 to ±3.4e38.
The double value ranges from approximately ±5.0e-324 to ±1.7e308.
The Decimal value ranges from approximately ±1.0e-28 to ±7.9e28.
Precision –
Float represent data with single precision.Double represent data with double precision.Decimal has higher precision than float and Double.
Float represent data with single precision.
Double represent data with double precision.
Decimal has higher precision than float and Double.
Accuracy –
Float is less accurate than Double and Decimal.Double is more accurate than Float but less accurate than Decimal.Decimal is more accurate than Float and Double.
Float is less accurate than Double and Decimal.
Double is more accurate than Float but less accurate than Decimal.
Decimal is more accurate than Float and Double.
For documentation related to Float , double and Decimal, kindly visit here.
Picked
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Clustered and Non-clustered index
Three address code in Compiler
Differences between IPv4 and IPv6
Introduction of Process Synchronization
Phases of a Compiler
Difference between DELETE, DROP and TRUNCATE
Segmentation in Operating System
Code Optimization in Compiler Design
Difference between Primary Key and Foreign Key
Peephole Optimization in Compiler Design