Since your question is mostly about performance, this article presents you with some specific calculations (keep in mind though that this article is specific to neural networks, and your calculations may be completely different to what they're doing in the article): http://web.archive.org/web/20150310213841/http://www.heatonresearch.com/content/choosing-between-java%E2%80%99s-float-and-double

Some of the relevant material from the link is reproduced here:

Both double and float can support relatively large numbers. The upper and lower range are really not a consideration for neural networks. Float can handle numbers between 1.40129846432481707e-45 to 3.40282346638528860e+38...Basically, float can handle about 7 decimal places. A double can handle about 16 decimal places.

Matrix multiplication is one of the most common mathematical operations for neural network programming. By no means is it the only operation, but it will provide a good benchmark. The following program will be used to benchmark a double.

Skipping all the code, the table on the website shows that for a 100x100 matrix multiplication, they have a gain in performance of around 10% if they use doubles. For a 500x100 matrix multiplication, the performance loss because of using doubles is around 7%. And for a 1000x1000 matrix multiplication, that loss is around 17%.

For the small 100x100 matrix switching to float may actually decrease performance. As the size of the matrix increases, the percent gain increases. With a very large matrix the performance gain increases to 17%. 17% is worth considering.

Answer from Nico on Stack Overflow
๐ŸŒ
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 - The output is true in the first example and false in second. We know that precisions of float and double are different. Size of mantissa for float is 24 and 53 for double. Let us consider the first example of 5.25. Binary representation of integral part is 101 and binary representation of part of the dot is 0.01 (needs only two bits) Let us consider the second example 5.1.
Top answer
1 of 5
12

Since your question is mostly about performance, this article presents you with some specific calculations (keep in mind though that this article is specific to neural networks, and your calculations may be completely different to what they're doing in the article): http://web.archive.org/web/20150310213841/http://www.heatonresearch.com/content/choosing-between-java%E2%80%99s-float-and-double

Some of the relevant material from the link is reproduced here:

Both double and float can support relatively large numbers. The upper and lower range are really not a consideration for neural networks. Float can handle numbers between 1.40129846432481707e-45 to 3.40282346638528860e+38...Basically, float can handle about 7 decimal places. A double can handle about 16 decimal places.

Matrix multiplication is one of the most common mathematical operations for neural network programming. By no means is it the only operation, but it will provide a good benchmark. The following program will be used to benchmark a double.

Skipping all the code, the table on the website shows that for a 100x100 matrix multiplication, they have a gain in performance of around 10% if they use doubles. For a 500x100 matrix multiplication, the performance loss because of using doubles is around 7%. And for a 1000x1000 matrix multiplication, that loss is around 17%.

For the small 100x100 matrix switching to float may actually decrease performance. As the size of the matrix increases, the percent gain increases. With a very large matrix the performance gain increases to 17%. 17% is worth considering.

2 of 5
10

Normally, I would use a double, because float doesn't have sufficient accuracy for many numerical use cases, and the performance difference is small enough not to matter.

As always, performance is implementation dependent so you will need to benchmark on your particular case in order to determine if it "matters" or not.

In general I have found:

  • The performance difference for individual operations is pretty small, especially on 64-bit machines. Both a float and a long will fit in a 64-bit machine word. Often there is zero difference.
  • floats have a slight advantage in that they consume less memory, and this can help with reducing CPU cache pressure. I've found floats to be 30-50% faster when doing simple operations over large arrays.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java numbers โ€บ float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - A float is a 32-bit single-precision floating-point type, occupying four bytes of memory. This compact size makes it well-suited for memory-constrained environments like embedded systems and mobile devices.
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ appficial
Java Floating Point Numbers - float and double - Java Tutorial - Appficial - YouTube
double and float are primitive data types for declaring floating-point numbers. double is more most commonly used because float is not precise. Variables dec...
Published: September 27, 2017
Views: 1K
๐ŸŒ
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.
๐ŸŒ
Medium
medium.com โ€บ codex โ€บ effective-java-avoid-float-and-double-if-exact-answers-are-required-fbdd9f8b9245
Effective Java: Avoid Float and Double If Exact Answers Are Required | by Kyle Carter | CodeX | Medium
June 26, 2021 - We must not use floats or doubles when we need exact answers, especially when dealing with numbers. Letโ€™s briefly go over why this is the case. The goal of floating point types is to allow the representation of any number with any number of digits before or after the decimal point. Unfortunately we arenโ€™t able to represent any number but the goal is still there. With a float we have 32 bits to use to represent all of this. In order to accomplish this Java implements the IEEE 754 standard.
๐ŸŒ
Codefinity
codefinity.com โ€บ blog โ€บ Float-vs-Double
Float vs Double
Both are used to represent floating ... storage requirements. The float type, typically a single-precision 32-bit IEEE 754 floating point, is used for decimal values that do not require extreme precision....
๐ŸŒ
Medium
medium.com โ€บ @ashish.kr.7724 โ€บ how-float-and-double-are-stored-in-java-memory-44fbb68fb1e8
How float and double Are Stored in Java Memory? | by Ashish Kr | Medium
March 10, 2026 - A float only has 23 bits for the mantissa. But 0.7 requires infinite bits in binary. ... A decimal number can be stored exactly in binary only if its simplified denominator is a power of 2. If the denominator contains any prime other than 2 โ†’ infinite binary โ†’ approximation required. ... It provides much higher precision. But even double cannot store 0.7 exactly.
๐ŸŒ
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?
Both data types represent numbers with decimals, but a float is 32 bits in size while a double is 64 bits. A double is twice the size of a float โ€” thus the term double. In Java, the Float and Double wrapper classes have two properties that ...
Published: May 23, 2026
๐ŸŒ
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 - As the Float consumes less memory in comparison to the Double data type. By default, Java treats any decimal or float numbers as double type, so in case, if we want to define any value as float, we need to manually typecast it using the 'f' or 'F' keyword in the suffix of the number.
๐ŸŒ
Medium
medium.com โ€บ @qingedaig โ€บ java-bigdecimal-vs-double-vs-float-012c7149e550
Java BigDecimal vs double vs float | by Alice Dai | Medium
October 15, 2024 - Memory: Use float when memory is a concern and lower precision is acceptable. Choosing the right data type depends on your specific needs regarding precision, performance, and the nature of the calculations you are performing. For most financial applications, BigDecimal is recommended, while double is commonly used for scientific computations.
๐ŸŒ
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.
๐ŸŒ
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.