float (the C# alias for System.Single) and double (the C# alias for System.Double) are floating binary point types. float is 32-bit; double is 64-bit. In other words, they represent a number like this:

10001.10010110011

The binary number and the location of the binary point are both encoded within the value.

decimal (the C# alias for System.Decimal) is a floating decimal point type. In other words, they represent a number like this:

12345.65789

Again, the number and the location of the decimal point are both encoded within the value โ€“ that's what makes decimal still a floating point type instead of a fixed point type.

The important thing to note is that humans are used to representing non-integers in a decimal form, and expect exact results in decimal representations; not all decimal numbers are exactly representable in binary floating point โ€“ 0.1, for example โ€“ so if you use a binary floating point value you'll actually get an approximation to 0.1. You'll still get approximations when using a floating decimal point as well โ€“ the result of dividing 1 by 3 can't be exactly represented, for example.

As for what to use when:

  • For values which are "naturally exact decimals" it's good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.

  • For values which are more artefacts of nature which can't really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won't be "decimally accurate" to start with, so it's not important for the expected results to maintain the "decimal accuracy". Floating binary point types are much faster to work with than decimals.

Answer from Jon Skeet on Stack Overflow
Top answer
1 of 16
2635

float (the C# alias for System.Single) and double (the C# alias for System.Double) are floating binary point types. float is 32-bit; double is 64-bit. In other words, they represent a number like this:

10001.10010110011

The binary number and the location of the binary point are both encoded within the value.

decimal (the C# alias for System.Decimal) is a floating decimal point type. In other words, they represent a number like this:

12345.65789

Again, the number and the location of the decimal point are both encoded within the value โ€“ that's what makes decimal still a floating point type instead of a fixed point type.

The important thing to note is that humans are used to representing non-integers in a decimal form, and expect exact results in decimal representations; not all decimal numbers are exactly representable in binary floating point โ€“ 0.1, for example โ€“ so if you use a binary floating point value you'll actually get an approximation to 0.1. You'll still get approximations when using a floating decimal point as well โ€“ the result of dividing 1 by 3 can't be exactly represented, for example.

As for what to use when:

  • For values which are "naturally exact decimals" it's good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.

  • For values which are more artefacts of nature which can't really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won't be "decimally accurate" to start with, so it's not important for the expected results to maintain the "decimal accuracy". Floating binary point types are much faster to work with than decimals.

2 of 16
1305

Precision is the main difference.

Float - 7 digits (32 bit)

Double-15-16 digits (64 bit)

Decimal -28-29 significant digits (128 bit)

Decimals have much higher precision and are usually used within financial applications that require a high degree of accuracy. Decimals are much slower (up to 20X times in some tests) than a double/float.

Decimals and Floats/Doubles cannot be compared without a cast whereas Floats and Doubles can. Decimals also allow the encoding or trailing zeros.

float flt = 1F/3;
double dbl = 1D/3;
decimal dcm = 1M/3;
Console.WriteLine("float: {0} double: {1} decimal: {2}", flt, dbl, dcm);

Result :

float: 0.3333333  
double: 0.333333333333333  
decimal: 0.3333333333333333333333333333
Discussions

mysql - What's difference between float, double and decimal in sql? - Stack Overflow
I was asked to add a column containg the bonuses of salary of employees, examples of this values were give such as: 1099.99 or 2.00. Task also asked me to add appropriate data type but I was confused More on stackoverflow.com
๐ŸŒ stackoverflow.com
Decimal or double? - Salesforce Stack Exchange
Double is 64-bit. I'm not sure what Decimal is behind the scenes. It might be BigDecimal like or something else ยท From Rich Unger (Regarding the type of Decimal a decimal is: For example, with Java you should never use floating point representations to handle monetary calculations, but instead ... More on salesforce.stackexchange.com
๐ŸŒ salesforce.stackexchange.com
August 17, 2015
mysql - Difference between float and decimal data type - Stack Overflow
Generally DECIMAL will store larger numbers and the math libs meet accountant's expectations, while double float is a less efficient storage medium that has massively optimized math libs - which meet scientists and finance (not accountants) guys expectations a lot better. More on stackoverflow.com
๐ŸŒ stackoverflow.com
int vs float vs double vs decimal

Amounts of memory allocated per variable.

Computational ease.

Computational speed.

More on reddit.com
๐ŸŒ r/C_Programming
8
4
January 15, 2020
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ csharp โ€บ language-reference โ€บ builtin-types โ€บ floating-point-numeric-types
Floating-point numeric types - C# reference | Microsoft Learn
1 week ago - Even numbers that are precise to only one decimal digit are handled more accurately by the decimal type: 0.1, for example, can be exactly represented by a decimal instance, while there's no double or float instance that exactly represents 0.1.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c# โ€บ difference-between-decimal-float-and-double-in-net
Difference between Decimal, Float and Double in .Net - GeeksforGeeks
July 23, 2025 - Float represent data with single precision. Double represent data with double precision. Decimal has higher precision than float and Double.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ whats-the-difference-between-decimal-float-and-double-in-net
What's the difference between decimal, float, and double in .NET?
Thatโ€™s why the precision of the decimal number is higher than that of float and double, but mostly it is much slower than float and double. This is because decimal operations are done in base 10 while floating-point operations are done in binary.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ mysql โ€บ decimal-vs-double-vs-float-in-mysql
Decimal vs Double vs Float in MySQL - GeeksforGeeks
July 23, 2025 - Decimal offers precise numeric storage with fixed-point arithmetic, suitable for financial data. Double and Float are approximate numeric types, where Double provides higher precision than Float.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_data_types_numbers.php
W3Schools.com
The float could not store the number exactly, so the last digits are wrong. The double stores it correctly.
Find elsewhere
๐ŸŒ
Code Maze
code-maze.com โ€บ home โ€บ float vs double vs decimal in c#: which to use?
Float vs Double vs Decimal in C#: Which to Use?
August 14, 2026 - Float, double and decimal are the three floating point types in C#, and the choice between them is nearly always the same: use double for most numbers, decimal for money, and float only when memory matters more than precision.
๐ŸŒ
Laravel Daily
laraveldaily.com โ€บ post โ€บ mysql-decimal-vs-double-vs-float
MySQL: Decimal vs Double vs Float?
September 14, 2023 - If you are okay being off by a few decimal places - use float, if you need to be precise - use decimal. Stock values (especially if products can be sold in measurements) - decimal, as you need to be precise.
๐ŸŒ
Codefinity
codefinity.com โ€บ blog โ€บ Float-vs-Double
Float vs Double
For the double type, you can consider up to 15 decimal digits to be precise and reliable. For the float type, up to 7 decimal digits are considered accurate.
๐ŸŒ
Coding Bolt
codingbolt.net โ€บ 2025 โ€บ 02 โ€บ 08 โ€บ decimal-vs-float-vs-double-in-c
Decimal vs. Float vs. Double in C# โ€“ Coding Bolt
February 8, 2025 - Double: Offers more precision (up to 15-16 digits), which makes it a better choice for most scientific computations. Its wider range makes it suitable for both very small and very large numbers.
๐ŸŒ
W3Schools
w3schools.com โ€บ cpp โ€บ cpp_data_types_numeric.asp
C++ Numeric Data Type
double myNum = 19.99; cout << myNum; ... can have after the decimal point. The precision of float is only six or seven decimal digits, while double variables have a precision of about 15 digits....
๐ŸŒ
Medium
medium.com โ€บ nerd-for-tech โ€บ float-double-decimal-in-c-which-one-should-you-use-3131ec7e2011
Float, Double, Decimal in C#: Which One Should You Use? | by Nagaraj | Medium
June 22, 2025 - This article gives you an insight into the float, double, and decimal types in C#. Step-by-step code samples, diagrams, and useful hints will aid you in picking out the best one for your situation.
๐ŸŒ
Codemia
codemia.io โ€บ home โ€บ knowledge hub โ€บ difference between decimal, float and double in .net?
Difference between decimal, float and double in .NET? | Codemia
September 23, 2025 - Use decimal for cases where precision is critical and the potential for rounding errors must be minimized. Use float when memory usage is a constraint, and speed is preferred over precision.
Top answer
1 of 3
2

Regarding to the official documentation, we have the next diferences:

  • FLOAT - Floating-Point Types (Approximate Value), uses four bytes
  • DOUBLE - Floating-Point Types (Approximate Value), uses eight bytes
  • DECIMAL - Fixed-Point Types (Exact Value)

You can ask about differences between floating and fixed datatypes, but this is not so easy to describe, try to read the same official documentation, or this article, for example.

2 of 3
2

Computer scientist Brian Kernighan wrote:

10.0 times 0.1 is hardly ever 1.0.

FLOAT and DOUBLE are both IEEE 754 format values. They store a wide range of floating-point value, including very small or very large values, but they have the disadvantage that they have rounding errors.

For examples and details on that, read:

  • https://dev.mysql.com/doc/refman/8.0/en/problems-with-float.html
  • https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

FLOAT stores 32 bits and DOUBLE stores 64 bits. This just means you can store more significant digits with a DOUBLE, but it still has the same rounding behavior.

These data types are good for scientific measurements like temperature, where the difference between 39 degrees and 38.999999997 degrees won't make a significant difference, especially if you're only doing things like averages or standard deviations.

Because of the rounding behavior, FLOAT and DOUBLE should never be used to store values of currency.

For currency values (e.g. the salaries you need to store), use DECIMAL.

DECIMAL and NUMERIC are exact scaled numerics. You define a column with a specific number of digits, and a specific number of digits to the right of the decimal point. There are no rounding problems; values you store come right back out exactly as you stored them. You can search the data for specific values.

DECIMAL and NUMERIC are synonyms. There's no difference. In fact, if you use NUMERIC as the type, MySQL silently replaces it with DECIMAL.

You may also like to read the chapter "Rounding Errors" in my book, SQL Antipatterns, Volume 1: Avoiding the Pitfalls of Database Programming.

๐ŸŒ
YouTube
youtube.com โ€บ devs school
Difference between double, float and decimal data types | C# - YouTube
In this video, we analyze the difference between double, float and decimal data types in C#.
Published: August 9, 2023
Views: 664
๐ŸŒ
TheServerSide
theserverside.com โ€บ blog โ€บ Coffee-Talk-Java-News-Stories-and-Opinions โ€บ Float-vs-Double-Whats-the-difference
Java double vs float: What's the difference?
The key difference between a float and double in Java is that a double can represent much larger numbers than a float. Both data types represent numbers with decimals, but a float is 32 bits in size while a double is 64 bits.
Published: May 23, 2026
๐ŸŒ
YouTube
youtube.com โ€บ orbit of the coding
Difference between Float, Double and Decimal in C# - YouTube
Comparison b/w them & also explain when to use float , double and Decimal.
Published: March 28, 2021
Views: 3K
Top answer
1 of 3
24

Biggest difference is the Double is a 64-bit and Decimal is not..... In addition:

Scientific notation (e) for Doubles is not supported.

Also, currency fields in salesforce are Decimals. The scale (number of digits to the right of decimal point) can be set for a Decimal, but cannot for a Double. This is important for currency and other calculations (division). Doubles do not have this option. You'll find that Doubles have a limited number of methods available to them compared to Decimals. Unless you know that you're dealing with very large numbers requiring a high degree of precision, Decimals will generally be a better choice.

Here is a good discussion on the issue from people way more experienced in the ins and outs than me:

From Peter Knoll:

According to the primitive data type docs currency fields are automatically assigned the type Decimal. Double is 64-bit. I'm not sure what Decimal is behind the scenes. It might be BigDecimal like or something else

From Rich Unger (Regarding the type of Decimal a decimal is:

For example, with Java you should never use floating point representations to handle monetary calculations, but instead use BigDecimal, and, as you stated you need to be careful with the comparisons. The same goes for Apex with respect to Double

SF Decimal is a BigDecimal

Run the following in Exec Anon and you'll see what I mean.

Double zeroPointZeroOne = 0.01;

Double sum = 0.0;
for (Integer i = 0; i < 10; i++) {
    sum += zeroPointZeroOne;
}

// 0.09999999999999999
System.debug('Double sum=' + sum); 

Decimal zeroPointZeroOneD = 0.01;
Decimal sumD = 0.0;
for (Integer i = 0; i < 10; i++) {
    sumD += zeroPointZeroOneD;
}

// 0.1
System.debug('Decimal sumD=' + sumD);

Comparing floating-point values

Its important to note that in the above Decimal example, in declaring Decimal sumD = 0.0;, the scale was set to 1, meaning 0.099 would be rounded up to 0.1 and 0.01 would be rounded down to 0.0. The default rounding would round 0.05 down to 0.0.

2 of 3
3

It depends what the number represents. If the number represents currency then Decimal is the way to go. In a Decimal every digit that you see is stored exactly as you see it and the number of decimal places and rounding modes are tightly defined. This avoids indeterminate results when large numbers are involved in intermediate or final values. Financial algorithms typically require that sort of control.

The strength of float/double is in representing numbers that vary hugely in size - 10 to the power of +/-38 for float and 10 to the power of +/-308 for double. Also there is direct hardware support for calculations on those making the calculation many orders of magnitude faster. But that only matters if running complex algorithms that perform many thousands of operations. The weakness is that the number of bits used to represent the value is limited and rounding errors can creep in surprisingly easily.

Unless you are doing complex scientific calculations Decimal is usually the best way to go.

Top answer
1 of 12
192

This is what I found when I had this doubt.

Use with AImysql> create table numbers (a decimal(10,2), b float);
mysql> insert into numbers values (100, 100);
mysql> select @a := (a/3), @b := (b/3), @a * 3, @b * 3 from numbers \G
*************************** 1. row ***************************
  @a := (a/3): 33.333333333
  @b := (b/3): 33.333333333333
@a + @a + @a: 99.999999999000000000000000000000
@b + @b + @b: 100

The decimal did exactly what's supposed to do on this cases, it truncated the rest, thus losing the 1/3 part.

So for sums the decimal is better, but for divisions the float is better, up to some point, of course. I mean, using DECIMAL will not give you a "fail proof arithmetic" in any means.

2 of 12
84

A "float" in most environments is a binary floating-point type. It can accurately store base-2 values (to a certain point), but cannot accurately store many base-10 (decimal) values. Floats are most appropriate for scientific calculations. They're not appropriate for most business-oriented math, and inappropriate use of floats will bite you. Many decimal values can't be exactly represented in base-2. 0.1 can't, for instance, and so you see strange results like 1.0 - 0.1 = 0.8999999.

Decimals store base-10 numbers. Decimal is an good type for most business math (but any built-in "money" type is more appropriate for financial calculations), where the range of values exceeds that provided by integer types, and fractional values are needed. Decimals, as the name implies, are designed for base-10 numbers - they can accurately store decimal values (again, to a certain point).