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
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › difference-between-float-and-double
Difference between Float and Double - GeeksforGeeks
July 23, 2025 - Float is a 32-bit type with single-precision, while double is a 64-bit type with double-precision. Float uses less memory but offers less precision, while double uses more memory but provides higher precision.
🌐
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.
Discussions

float vs. double – What's the Key Difference?"
There's usually not an appreciable performance difference between single operations on floats and doubles, but when you do a lot of operations on a lot of numbers, you can get performance benefits from being able to load 2x of them with the same memory bandwidth, and do 2x the operations in similar time by packing in more SIMD lanes with a few cycles less for each. ... Quick example... More on reddit.com
🌐 r/learnprogramming
12
16
November 2, 2024
c++ - When do you use float and when do you use double - Software Engineering Stack Exchange
Frequently, in my programming experience, I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this fe... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
February 28, 2013
Why would I use float data type instead of double? (C++)

double has more precision and is larger than a float. Generally, a double is 8 bytes and a float is 4 bytes. But sometimes you don't need that extra precision, and a float can work fine. So hence sometimes use float instead of a double. i.e. why waste space using a double if you don't need that extra precision?

More on reddit.com
🌐 r/learnprogramming
4
2
January 19, 2019
Float or double?

A pair of doubles for location on Earth to sub-metre accuracy? A pair of 32-bit integers will let you store it to the nearest centimetre.

Sometimes you need to ask if a floating point is even right for your use case.

More on reddit.com
🌐 r/programming
387
952
June 5, 2017
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.

🌐
Codefinity
codefinity.com › blog › Float-vs-Double
Float vs Double
Python does not have a separate float and double type distinction. It uses double precision floating-point numbers for all decimal values. Here's how you define a floating point number in Python: my_float = 3.14 # Python uses 64-bit IEEE 754 double precision by default · JavaScript does not differentiate between different types of floating point numbers; it only has one data type for decimals — number, which is implemented as double-precision floating point according to IEEE 754.
🌐
freeCodeCamp
freecodecamp.org › news › double-vs-float-in-cpp-the-difference-between-floats-and-doubles
Double VS Float in C++ – The Difference Between Floats and Doubles
May 19, 2022 - The byte size for float is 4 while the byte size for double is 8. This implies that double can store values that are twice the amount that float can hold. We can see this by using the sizeof() operator.
🌐
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?
Assign a value within the range of a float. ... When Java encounters a decimal in a program, or a calculation generates a floating point number, Java treats the number as a double. For example, both of the following lines of code fail to compile because Java assumes that any decimal is a double.
Published: May 23, 2026
🌐
Educative
educative.io › answers › what-is-the-difference-between-float-and-double
What is the difference between float and double?
Float and double are both widely used data types in programming that have the ability to store decimal or floating-point​ numbers. The only difference between them is the precision.
Find elsewhere
🌐
Unstop
unstop.com › home › blog › 10+ difference between float and double explained (+examples)
10+ Difference Between Float And Double Explained (+Examples)
December 3, 2024 - Float has limited precision and a smaller range, which can lead to rounding errors and issues with very large or very small numbers. It’s also prone to overflow and underflow in extreme cases.
🌐
Hackr
hackr.io › home › articles › programming
Float vs Double Data Types: What's The Difference [Updated]
January 30, 2025 - This leads me to my main point: ... application's needs. For example, If you need to conserve memory and your calculations don't require extreme precision, Floats might be sufficient....
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - In contrast, a double is a 64-bit double-precision floating-point type, requiring eight bytes of memory. While it demands more storage, this larger size allows it to represent values with higher precision and a broader range, making it indispensable ...
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › difference-float-double-c-cpp
Difference between float and double in C/C++ - GeeksforGeeks
June 23, 2023 - What's the difference? double has 2x more precision than float. float is a 32-bit IEEE 754 single precision Floating Point Number - 1 bit for the sign, 8 bits for the exponent, and 23* for the value. float has 7 decimal digits of precision. ...
🌐
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 - There's usually not an appreciable performance difference between single operations on floats and doubles, but when you do a lot of operations on a lot of numbers, you can get performance benefits from being able to load 2x of them with the same memory bandwidth, and do 2x the operations in similar time by packing in more SIMD lanes with a few cycles less for each. ... Quick example: float pi_float = 3.14159265359f; // Stores as 3.1415927 double pi_double = 3.14159265359; // Stores as 3.14159265359
🌐
Blogger
javarevisited.blogspot.com › 2016 › 05 › difference-between-float-and-double-in-java.html
Difference between float and double variable in Java? Example
July 26, 2023 - It's also best practice to choose ... of the main difference between float and double is that (i) Float requires 4 bytes of storage while double requires 8 bytes....
🌐
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
Because the leading 1 in normalized binary numbers ($1.b_1b_2b_3...$) is implicit, the effective precision is 24 bits for float and 53 bits for double. ... Why it matters: While 4 bytes difference is negligible for a single variable, memory allocation scales linearly with dataset size:
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.

🌐
Study.com
study.com › business courses › java programming tutorial & training
Java: Float vs. Double - Lesson | Study.com
July 21, 2018 - I can research almost any subject, delve into it more deeply if I wish, and begin studying at a deeper level right away. Catherine S. ... Typically, a double scoop of ice cream is more than a float. The same is true in Java, but on a different scale.
🌐
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 - In this case, a float data type might be utilized because minor differences in decimal values would not significantly influence gameplay. On the other hand, when dealing with exact measurements in astronomical investigations, a double data type assures that no delicate information is lost. ...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-float-and-double
C Float and Double - GeeksforGeeks
June 12, 2026 - Double is used to store double precision floating point values. It is the greater version of float which can store real numbers with precision up to 15 decimal places.
🌐
Tech Differences
techdifferences.com › home › difference between float and double
Difference Between Float and Double (with Comparison Chart) - Tech Differences
December 25, 2019 - Float and Double both are the data types under Floating-point type. The Floating-point numbers are the real numbers that have a fractional component in it. The primary difference between float and double is that the float type has 32-bit storage.
🌐
Educative
educative.io › blog › float-vs-double-in-java
Float vs. double in Java
In large arrays or high-throughput systems (for example graphics, audio, embedded sensor processing), using float may reduce memory footprint and improve cache efficiency. However, in many server-side Java applications the difference in memory is relatively small compared to overall heap usage, and double offers better precision with negligible performance penalty on modern hardware.