Huge difference.

As the name implies, a double has 2x the precision of float[1]. In general a double has 15 decimal digits of precision, while float has 7.

Here's how the number of digits are calculated:

double has 52 mantissa bits + 1 hidden bit: log(253)÷log(10) = 15.95 digits

float has 23 mantissa bits + 1 hidden bit: log(224)÷log(10) = 7.22 digits

This precision loss could lead to greater truncation errors being accumulated when repeated calculations are done, e.g.

float a = 1.f / 81;
float b = 0;
for (int i = 0; i < 729; ++ i)
    b += a;
printf("%.7g\n", b); // prints 9.000023

while

double a = 1.0 / 81;
double b = 0;
for (int i = 0; i < 729; ++ i)
    b += a;
printf("%.15g\n", b); // prints 8.99999999999996

Also, the maximum value of float is about 3e38, but double is about 1.7e308, so using float can hit "infinity" (i.e. a special floating-point number) much more easily than double for something simple, e.g. computing the factorial of 60.

During testing, maybe a few test cases contain these huge numbers, which may cause your programs to fail if you use floats.


Of course, sometimes, even double isn't accurate enough, hence we sometimes have long double[1] (the above example gives 9.000000000000000066 on Mac), but all floating point types suffer from round-off errors, so if precision is very important (e.g. money processing) you should use int or a fraction class.


Furthermore, don't use += to sum lots of floating point numbers, as the errors accumulate quickly. If you're using Python, use fsum. Otherwise, try to implement the Kahan summation algorithm.


[1]: The C and C++ standards do not specify the representation of float, double and long double. It is possible that all three are implemented as IEEE double-precision. Nevertheless, for most architectures (gcc, MSVC; x86, x64, ARM) float is indeed a IEEE single-precision floating point number (binary32), and double is a IEEE double-precision floating point number (binary64).

Answer from kennytm on Stack Overflow
Top answer
1 of 14
650

Huge difference.

As the name implies, a double has 2x the precision of float[1]. In general a double has 15 decimal digits of precision, while float has 7.

Here's how the number of digits are calculated:

double has 52 mantissa bits + 1 hidden bit: log(253)÷log(10) = 15.95 digits

float has 23 mantissa bits + 1 hidden bit: log(224)÷log(10) = 7.22 digits

This precision loss could lead to greater truncation errors being accumulated when repeated calculations are done, e.g.

float a = 1.f / 81;
float b = 0;
for (int i = 0; i < 729; ++ i)
    b += a;
printf("%.7g\n", b); // prints 9.000023

while

double a = 1.0 / 81;
double b = 0;
for (int i = 0; i < 729; ++ i)
    b += a;
printf("%.15g\n", b); // prints 8.99999999999996

Also, the maximum value of float is about 3e38, but double is about 1.7e308, so using float can hit "infinity" (i.e. a special floating-point number) much more easily than double for something simple, e.g. computing the factorial of 60.

During testing, maybe a few test cases contain these huge numbers, which may cause your programs to fail if you use floats.


Of course, sometimes, even double isn't accurate enough, hence we sometimes have long double[1] (the above example gives 9.000000000000000066 on Mac), but all floating point types suffer from round-off errors, so if precision is very important (e.g. money processing) you should use int or a fraction class.


Furthermore, don't use += to sum lots of floating point numbers, as the errors accumulate quickly. If you're using Python, use fsum. Otherwise, try to implement the Kahan summation algorithm.


[1]: The C and C++ standards do not specify the representation of float, double and long double. It is possible that all three are implemented as IEEE double-precision. Nevertheless, for most architectures (gcc, MSVC; x86, x64, ARM) float is indeed a IEEE single-precision floating point number (binary32), and double is a IEEE double-precision floating point number (binary64).

2 of 14
64

Here is what the standard C99 (ISO-IEC 9899 6.2.5 §10) or C++2003 (ISO-IEC 14882-2003 3.1.9 §8) standards say:

There are three floating point types: float, double, and long double. The type double provides at least as much precision as float, and the type long double provides at least as much precision as double. The set of values of the type float is a subset of the set of values of the type double; the set of values of the type double is a subset of the set of values of the type long double.

The C++ standard adds:

The value representation of floating-point types is implementation-defined.

I would suggest having a look at the excellent What Every Computer Scientist Should Know About Floating-Point Arithmetic that covers the IEEE floating-point standard in depth. You'll learn about the representation details and you'll realize there is a tradeoff between magnitude and precision. The precision of the floating point representation increases as the magnitude decreases, hence floating point numbers between -1 and 1 are those with the most precision.

Top answer
1 of 8
219

The default choice for a floating-point type should be double. This is also the type that you get with floating-point literals without a suffix or (in C) standard functions that operate on floating point numbers (e.g. exp, sin, etc.).

float should only be used if you need to operate on a lot of floating-point numbers (think in the order of thousands or more) and analysis of the algorithm has shown that the reduced range and accuracy don't pose a problem.

long double can be used if you need more range or accuracy than double, and if it provides this on your target platform.

In summary, float and long double should be reserved for use by the specialists, with double for "every-day" use.

2 of 8
48

There is rarely cause to use float instead of double in code targeting modern computers. The extra precision reduces (but does not eliminate) the chance of rounding errors or other imprecision causing problems.

The main reasons I can think of to use float are:

  1. You are storing large arrays of numbers and need to reduce your program's memory consumption.
  2. You are targeting a system that doesn't natively support double-precision floating point. Until recently, many graphics cards only supported single precision floating points. I'm sure there are plenty of low-power and embedded processors that have limited floating point support too.
  3. You are targeting hardware where single-precision is faster than double-precision, and your application makes heavy use of floating point arithmetic. On modern Intel CPUs I believe all floating point calculations are done in double precision, so you don't gain anything here.
  4. You are doing low-level optimization, for example using special CPU instructions that operate on multiple numbers at a time.

So, basically, double is the way to go unless you have hardware limitations or unless analysis has shown that storing double precision numbers is contributing significantly to memory usage.

Discussions

When should I use double and when should I use float for Java?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
65
59
January 6, 2024
float vs. double – What's the Key Difference?"
16 votes, 12 comments. New to programming and curious: what's the main difference between float and double? When should I use one over the other?… More on reddit.com
🌐 r/learnprogramming
12
16
November 2, 2024
[C] How to know when to use a double vs float or a long vs int?
you should use double over float whenever possible IMO - it makes numbers orders of magnitude more accurate, there's basically no downside. More on reddit.com
🌐 r/learnprogramming
7
1
November 28, 2017
[deleted by user]
If you don't know what you're doing, the safest thing to do is stick with double. Correctly using less precision requires care and understanding . However, even though machines today have tons of storage compared to 20 years go, float is still as important as ever. If you're working with large amounts of data, those savings still matter. Single precision is also faster in general: slightly better latency, less cache pressure, and, in certain specialized situations (SIMD), they can literally twice as fast. More on reddit.com
🌐 r/C_Programming
15
1
January 30, 2019
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › difference-between-float-and-double
Difference between Float and Double - GeeksforGeeks
July 23, 2025 - The key difference is their precision and storage size. A float is typically a 32-bit number with a precision of about 7 decimal digits, while a double is a 64-bit number with a precision of about 15 decimal digits.
🌐
Codefinity
codefinity.com › blog › Float-vs-Double
Float vs Double
In programming, choosing between float and double can significantly affect the precision of the calculations and the overall performance of the application. They are crucial in fields such as scientific computing, graphics programming, and any ...
🌐
tutorialpedia
tutorialpedia.org › blog › what-is-the-difference-between-float-and-double
Float vs Double: Key Differences Explained, When They're Interchangeable & When to Use Each — tutorialpedia.org
Yes, but in most languages, expressions containing both float and double automatically promote the float operands to double. The result of the expression will be a double. If assigned back to a float, an explicit cast is required, potentially losing precision. Understanding the distinction between float and double boils down to balancing precision, dynamic range, and memory footprint:
🌐
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
🌐
Educative
educative.io › answers › what-is-the-difference-between-float-and-double
What is the difference between float and double?
A double is a 64-bit IEEE 754 double-precision floating-point number. 1 bit for the sign, 11 bits for the exponent, and 52 bits for the value. A double has 15 decimal digits of precision and occupies a total of 64 bits.
🌐
Educative
educative.io › blog › float-vs-double-in-java
Float vs. double in Java
As stated earlier in this blog, the primary contrast between float and double lies in their precision. According to the IEEE 754 standard, a float is a 32-bit binary format, while double is a 64-bit binary format. The difference in the number of bits used for an exponent and a mantissa is ...
Find elsewhere
🌐
Programiz
programiz.com › cpp-programming › float-double
C++ float and double | Programiz
August 23, 2024 - However, since float has a precision of up to only 7 digits, it shows garbage values after its precision is exceeded. Our double variable shows the correct number because it has a precision of 15 digits, while the number itself consists of 13 digits.
🌐
Unstop
unstop.com › home › blog › 10+ difference between float and double explained (+examples)
10+ Difference Between Float And Double Explained (+Examples)
December 3, 2024 - Simple Financial Applications: In scenarios where exact precision isn’t critical, such as budget calculations for small-scale projects, floats can be used. Memory Efficient: Requires only 4 bytes, suitable for memory-constrained environments. Fast Computation: Ideal for performance-critical applications like graphics rendering. Limited Precision: Accurate up to 6-7 decimal places, unsuitable for sensitive calculations. Smaller Range: More prone to overflow or underflow in extreme values. The double data type is a double-precision 64-bit IEEE 754 floating-point format.
🌐
FavTutor
favtutor.com › blogs › java-float-vs-double
Java: Float vs Double | 4 Main Differences (& when to use?) | FavTutor
February 23, 2021 - We also included a comparison table for float vs double in java programming. Broadly, data can be divided into two main types: numeric and non-numeric data. Non-numeric data include characters and strings. Numeric data consists of whole numbers and floating-point numbers. Whole numbers, like the name, says, have only a whole part – there is no fraction involved. Floating-point numbers, on the other hand, come with a fractional part and a whole part out of the box.
🌐
Scaler
scaler.com › home › topics › difference between float and double in c/c++
Difference between float and double in C/C++ - Scaler Topics
April 22, 2024 - Compared to float, the double data type provides double the accuracy. It can carry a wider range of numbers and has better precision, making it suited for difficult mathematical operations requiring absolute precision.
🌐
C++ Better Explained
cppbetterexplained.com › home › posts › c++ float vs double: which one should you use? | cppbe
C++ float vs double: Which One Should You Use? | CppBE
July 29, 2026 - If you remember nothing else: default to double, and only switch to float when memory or a specific API demands it. You’ll avoid an entire class of subtle precision bugs that beginners spend hours debugging.
🌐
Hackr
hackr.io › home › articles › programming
Float vs Double Data Types: What's The Difference [Updated]
January 30, 2025 - Explanation: This C code declares a float and a double, each initialized with Pi to many decimal places. The printf function demonstrates the difference in precision: float cuts off after 7 decimal places, while double goes much further.
🌐
How Not To Code
hownot2code.wordpress.com › 2017 › 06 › 09 › float-or-double
Float or double? | How Not To Code - WordPress.com
June 9, 2017 - Here are some rough figures on the worst-case precision you would get if you used float vs double to measure things of different ranges: (example: using a double you can represent the time since the big bang with a precision of around one minute). So: if you are measuring the size of your apartment float will do fine. If you want to represent GPS coordinates with sub-meter precision, you will need double. If you have plenty of RAM and neither execution speed or battery drainage is a problem for you – you can stop reading now and just use double.
🌐
Reddit
reddit.com › r/learnprogramming › float vs. double – what's the key difference?"
r/learnprogramming on Reddit: float vs. double – What's the Key Difference?"
November 2, 2024 - The difference is memory size. Floats in Java (which I assume is the language you’re talking about) take up 32 bits of memory, the same as an integer. Doubles, as you might guess from the name, take up double the space: 64 bits.
🌐
TechGeekBuzz
techgeekbuzz.com › home › blog › difference › float vs double – decoding differences between data types
Float vs Double – Decoding Differences Between Data Types
The major difference between float and double lies in the precision. Precision refers to accuracy. In data science or scientific computing, precision plays a vital role. Even a single decimal point can have a huge impact.
🌐
Great Assignment Help
us.greatassignmenthelp.com › home › get to know the significant differences between float vs. double
Get To Know The Significant Differences Between Float Vs. Double
September 27, 2025 - However, Double variables consume more memory space than float variables. To declare a data type as double, it is essential to input the code with the keyword “double”. The name of the variable and an optional initial value must accompany it.
🌐
Wikitechy
wikitechy.com › float-and-double-in-programming
🧮 Float and Double in Programming: Meaning, Size, Range, and Key Differences in 2025 - Wikitechy
September 25, 2025 - Speed and memory → go with float. Accuracy and precision → go with double. ... 👉 Developer insight: Don’t memorize this table for interviews—understand the trade-off between speed vs. precision.