A float is a 32 bit IEEE 754 floating point.

A double is a 64 bit IEEE 754 floating point.

so it is just a matter of precision because neither of the fraction portions .8 and .65 have a terminating binary representation, so there is some rounding error. the double has more precision so it has slightly less rounding error.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

Answer from Ross Larson on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › double-doublevalue-method-in-java-with-examples
Double doubleValue() method in Java with examples - GeeksforGeeks
July 11, 2025 - // Java code to demonstrate // Double doubleValue() method class GFG { public static void main(String[] args) { // Double value Double a = 17.47; // wrapping the Double value // in the wrapper class Double Double b = new Double(a); // doubleValue ...

A float is a 32 bit IEEE 754 floating point.

A double is a 64 bit IEEE 754 floating point.

so it is just a matter of precision because neither of the fraction portions .8 and .65 have a terminating binary representation, so there is some rounding error. the double has more precision so it has slightly less rounding error.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

Answer from Ross Larson on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string. The string is converted to a double value as if by the valueOf method. ... NumberFormatException - if the string does not contain a parsable number. ... Returns a string representation of the double argument.
🌐
Wikipedia
en.wikipedia.org › wiki › Double-precision_floating-point_format
Double-precision floating-point format - Wikipedia
January 9, 2026 - Given the hexadecimal representation 3FD5 5555 5555 555516, Sign = 0 Exponent = 3FD16 = 1021 Exponent Bias = 1023 (constant value; see above) Fraction = 5 5555 5555 555516 Value = 2(Exponent − Exponent Bias) × 1.Fraction – Note that Fraction ...
🌐
Codefinity
codefinity.com › blog › Float-vs-Double
Float vs Double
Q: How do Float and Double handle very large or very small numbers? A: Both types manage large and small numbers using scientific notation. However, double has a significantly larger range and precision, making it capable of handling much larger or smaller values compared to float.
🌐
Microsoft Learn
learn.microsoft.com › en-us › office › vba › language › reference › user-interface-help › double-data-type
Double data type | Microsoft Learn
September 13, 2021 - 4.94065645841247E-324 to 1.79769313486232E308 for positive values · The type-declaration character for Double is the number (#) sign.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › lang › pdf › number_doublevalue.pdf pdf
java.lang.number.doublevalue method
This method returns the numeric value represented by this object after conversion to type double. Exception · NA · Example · The following example shows the usage of lang.Number.doubleValue method. package com.tutorialspoint; public class NumberDemo { public static void main(String[] args) { // get a number as integer ·
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Format-double-Java-printf-example
How to format a Java double with printf example
To use Java printf to format double and float values with decimal place precision, follow these two rules: Use %f as the double specifier in the text string. Precede the letter f with a decimal and number to specify precision. Here is a simple example of both a float and double being formatted with Java’s printf function:
🌐
DataCamp
datacamp.com › doc › java › double
double Keyword in Java: Usage & Examples
This example shows the use of a double array. The array temperatures is initialized with four double values.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java double value method
Java Double Value Method
September 1, 2008 - This method returns the double value after conversion. The following example shows the usage of Java Number doubleValue() method. Here, we are instantiating an Integer object and initializing it. The method is then invoked on this object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-number-doublevalue-method
Java Number.doubleValue() Method - GeeksforGeeks
May 15, 2025 - The double data type can hold fractional values, so, it is useful for converting integer-based values when working with mixed-type arithmetic expressions. Example 1: In this example, we are going to convert Integer and Float into double using Number.doubleValue() method.
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-doublevalue-method-in-java
Integer doubleValue() Method in Java - GeeksforGeeks
July 7, 2018 - // Code to illustrate doubleValue() ... a = new Integer(14); // Convert Integer number to double value double b = a.doubleValue(); System.out.println(b); } }...
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › jdk.jdi › com › sun › jdi › DoubleValue.html
DoubleValue (Java SE 11 & JDK 11 )
January 20, 2026 - true if the Object is a DoubleValue and if applying "==" to the two mirrored primitives would evaluate to true; false otherwise. ... Returns the hash code value for this DoubleValue.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › fundamentals › runtime-libraries › system-double
System.Double struct - .NET | Microsoft Learn
February 21, 2025 - Its least significant digit is thousandths, whereas the most significant digit in the product is 10-309. using System; public class Example14 { public static void Main() { Double value = 123456789012.34567; Double additional = Double.Epsilon ...
🌐
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.
🌐
University of Texas
cs.utexas.edu › ~mooney › ir-course › doc › ir › utilities › DoubleValue.html
DoubleValue
A simple wrapper data structure for storing a double real value as an Object whose value can be reset.
🌐
Xojo Programming Forum
forum.xojo.com › general
If some values can't be represented as a Double, then what am I to use? - General - Xojo Programming Forum
May 19, 2021 - For example, consider this code: Var d1 As Double = 5.1 Var d2 As Double = d1 * 100 Var d3 As Double = Round(d1 * 100) The value 5.1 cannot be stored directly in a Double (it’s actually more like 5.0999999999999996).