Doubles take up twice the amount of memory as floats do (hence the name) but as a result they are more precise and can represent a wider range of values. Memory space doesn’t matter as much as it used to so for most use cases, doubles are just fine. In certain applications though where speed and performance is a higher priority than accuracy, such as graphics calculations for video games, using floats instead of doubles may be preferable. Answer from Quantum-Bot on reddit.com
🌐
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.
🌐
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 -

New to programming and curious: what's the main difference between float and double? When should I use one over the other?

Thanks! 🙏😊

Top answer
1 of 5
19
It can depend on the language spec, but usually the amount of memory and therefore the precision allowed by the type. Usually: A double will use 8 bytes or 64 bits of memory while a float uses only 4 bytes or 32 bits. This means that a float is less precise since it can store fewer digits after the decimal place. The way it works is that some bits of the datatype are used for the whole number portion of the number and some for the decimal portion. So as you can see, double, using more memory can have more bits allocated to the decimal portion making it more precise. See balefrost's reply to my comment for a correct explanation of this. Using float means using less memory, having more efficient code (due to lower precision so saving on calculations) and handling a smaller range of numbers (floats handle a smaller range than double due to reduced memory usage). Hope this helps!
2 of 5
3
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. Doubles use those extra bits to both store a wider range of numbers and add more precision to the numbers they can store as well. There’s really seldom any reason to use floats in modern Java applications since memory is no longer a limiting factor for most programs. However, back in the day memory used to be much more limited so you would stick to regular floats as long as they were good enough for what you’re doing and only use doubles when absolutely necessary. This was starting to change even as Java was first created, but a lot of things in Java were designed to make the transition easier for programmers who were used to using C, a popular language at the time.
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - This test checks that when a value exceeds the lower bound of the float‘s range, it correctly underflows to zero, as expected for values too small to be represented. Choosing between float and double in Java requires understanding the trade-offs in precision, memory usage, and application needs.
🌐
Scaler
scaler.com › home › topics › float vs double in java - difference you should know
Float Vs Double in Java - Difference You Should Know - Scaler Topics
March 27, 2024 - We use this Float data type, if we want to use the memory efficiently, or if the number is in the small range. As the Float consumes less memory in comparison to the Double data type.
🌐
Blogger
javahungry.blogspot.com › 2019 › 11 › difference-between-float-and-double-in-java.html
7 Difference Between float and double Datatypes in Java | Java Hungry
Data loss is expected when double is converted to float. 5. Default datatype : float is not the default data type value of floating point literals. double is the default data type of floating point literals. 6. Wrapper class : Wrapper class for float is java.lang.Float.
Find elsewhere
🌐
Blogger
javarevisited.blogspot.com › 2016 › 05 › difference-between-float-and-double-in-java.html
Difference between float and double variable in Java? Example
Though both float and double datatype are used to represent floating-point numbers in Java, a double data type is more precise than float. A double variable can provide precision up to 15 to 16 decimal points as compared to float precision of ...
🌐
Javatpoint
javatpoint.com › float-vs-double-java
Float Vs Double Java - Javatpoint
Float Vs Double Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Simplilearn
simplilearn.com › home › resources › software development › float vs double in java: key differences you should know
Float vs Double in Java: Key Differences You Should Know
November 17, 2025 - Explore the key differences between float and double in Java. Our comprehensive guide helps you choose the right type for your Java applications. Perfect for new coders!
🌐
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. As a guideline: if your application processes millions of values, and the required precision is modest, float may make sense; otherwise default to double unless you know you must optimize.
🌐
FavTutor
favtutor.com › blogs › java-float-vs-double
Java: Float vs Double | 4 Main Differences (& when to use?) | FavTutor
February 23, 2021 - This loss of bits from the end of the number is very pronounced while using float. The number of bits lost is much lesser while using double because of the large number of bits allocated for the exponent. Default: Double is the default data type used by Java for dealing with fractional numbers.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › top differences tutorial › java float vs double
Java float vs Double | Top 7 Beneficial Comparisons To Learn
January 11, 2024 - When representing a float data type in Java, we should append the letter f to the end of the data type; otherwise, it will save as double. Double data type stores decimal values with 15-16 digits of precision.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
GeeksforGeeks
geeksforgeeks.org › java › comparison-of-double-and-float-primitive-types-in-java
Comparison of double and float primitive types in Java - GeeksforGeeks
March 6, 2023 - But binary representation of 0.1 is 1/16 + 1/32 + 1/64 + 1/128 ..... and so on until we reach the end of mantissa or sum becomes more than 0.1. In this case, we reach the end of mantissa and therefore the value of 5.1 becomes different in float and double. Tabular difference between Double and Float in Java:
🌐
Coderanch
coderanch.com › t › 497381 › java › whats-difference-float-double
whats the difference between float & double (Beginning Java forum at Coderanch)
Float and double values are not integers, but rather floating point numbers. The Java integer types are: byte, short, int, long (and char - 16 bits unsigned). In both cases your code is comparing a float value to a double, as the compiler sees 3.2f as a float and 3.2 (without the f) as a double.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › difference-between-float-and-double
Difference between Float and Double - GeeksforGeeks
July 23, 2025 - roots of equation x^2- 4.0000000 x + 3.9999999= 0 are: for float values: 2.00000 2.00000 for double values: 2.00032 1.99968
🌐
Medium
medium.com › @qingedaig › java-bigdecimal-vs-double-vs-float-012c7149e550
Java BigDecimal vs double vs float | by Alice Dai | Medium
October 15, 2024 - Avoiding Floating-Point Errors: When exact decimal representation is crucial, like when comparing values or storing precise numbers. import java.math.BigDecimal; public class BigDecimalExample { public static void main(String[] args) { BigDecimal price = new BigDecimal("19.99"); BigDecimal tax = new BigDecimal("0.07"); BigDecimal totalPrice = price.add(price.multiply(tax)); System.out.println("Total Price: " + totalPrice); } } Performance: Use double for general-purpose floating-point arithmetic where performance is a consideration and exact precision is not critical.