In Java, when you type a decimal number as 3.6, its interpreted as a double. double is a 64-bit precision IEEE 754 floating point, while floatis a 32-bit precision IEEE 754 floating point. As a float is less precise than a double, the conversion cannot be performed implicitly.

If you want to create a float, you should end your number with f (i.e.: 3.6f).

For more explanation, see the primitive data types definition of the Java tutorial.

Answer from Nicolas on Stack Overflow
🌐
W3Schools
w3schools.com › java › ref_keyword_float.asp
Java float Keyword
Java Examples Java Videos Java ... Interview Q&A Java Certificate ... The float keyword is a data type that can store fractional numbers from 3.4e−038 to 3.4e+038....
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
ELI5:Java. Could someone explain what the data type 'float' is and how/why it should be used? Thanks
Basically floats are numbers which are stored with a fractional, or decimal part. For example, if you write: int myInt = 5.23; float myFloat = 5.23; System.out.println(myInt); System.out.println(myFloat); You will see the output: 5 5.23 Because the figures after the decimal point were not stored in the int type variable. Edit: Sorry for the bad formatting... Apparantly I don't know how to line break on reddit. Double Edit: Nevermind, figured it out More on reddit.com
🌐 r/explainlikeimfive
7
0
November 22, 2013
memory - Why are floats still part of the Java language when doubles are mostly recommended instead? - Software Engineering Stack Exchange
In every place I've looked, it says that double is superior to float in almost every way. float has been made obsolete by double in Java, so why is it still used? I program a lot with Libgdx, and ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
April 26, 2016
How do i know what "float 1e1f" in Java is?
The e is scientific notation shorthand for "* 10^". Example: 5e3 = 5 * 103 = 5000 8e-5 = 8 * 10-5 = 0.00008 The f just indicates that the number is a float. More on reddit.com
🌐 r/learnprogramming
9
4
June 20, 2015
🌐
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.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Float.html
Float (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is float.
🌐
DataCamp
datacamp.com › doc › java › float
float Keyword in Java: Usage & Examples
Learn about the `float` keyword in Java, a 32-bit single-precision data type for memory-efficient floating point numbers. Includes syntax, usage examples, and best practices.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-illustrate-the-usage-of-floating
Java Program to Illustrate the Usage of Floating - GeeksforGeeks
September 7, 2021 - Float: It is a single-precision value that has 32 bits in storage. and this single precision is faster and does take less size compared to double precision. For java variables, we can use float while declaring or initializing for expected value ...
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - This article explores these differences in detail, aiming to guide developers in choosing the right type for tasks such as scientific computations, graphics processing, and financial analyses. Java provides two primitive data types for floating-point arithmetic: float and double. Both adhere to the IEEE 754 standard, ensuring consistent behavior across platforms. However, their size, precision, and performance differ significantly. The memory size of float and double is a fundamental distinction that directly impacts their storage capabilities and memory consumption.
🌐
Quora
quora.com › How-is-a-float-or-double-value-stored-in-memory-in-java
How is a float or double value stored in memory in java? - Quora
Answer (1 of 6): There used to be a bunch of ways of storing floats and doubles in the bad old days, but they were standardized so that they could be hardware accelerated. Adding hardware acceleration to math was a major trend in computing back in the nineties, and was something of a predecessor ...
🌐
Android Developers
developer.android.com › api reference › float
Float | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
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 - Floating-point numbers are numbers that can have a decimal point, such as 3.14159 or 1.23456789e10. Float is a 32-bit floating-point number, which means that it can store up to 7 decimal digits ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-number-floatvalue-method
Java Number.floatValue() Method - GeeksforGeeks
May 15, 2025 - The float data type has limited precision that is 32-bit, so, the method may truncate or round the value when converting from a higher precise type like double or long. ... Parameters: This method does not accept any parameters.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.float
Float Class (Java.Lang) | Microsoft Learn
[<Android.Runtime.Register("ja... IJavaObject interface IDisposable interface IJavaPeerable ... The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is ...
🌐
Oracle
docs.oracle.com › en › java › javase › 24 › docs › api › java.base › java › lang › Float.html
Float (Java SE 24 & JDK 24)
July 15, 2025 - In addition, this class provides ... with a float. This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail. The class java.lang.Double ...
🌐
MIT
web.mit.edu › java_v1.0.2 › www › javadoc › java.lang.Float.html
Class java.lang.Float
Returns true if the specified number is the special Not-a-Number (NaN) value. ... Returns the long value of this Float (by casting to a long). ... Returns a String representation of this Float object. ... Returns a String representation for the specified float value. ... Returns the floating point value represented by the specified String. ... Positive infinity.
🌐
DZone
dzone.com › coding › java › understanding floating-point precision issues in java
Understand Floating-Point Precision Issues in Java
September 12, 2024 - All Java developers know them but can't answer a simple question described in the following meme: ... float and double represent floating-point numbers. float uses 32 bits, while double uses 64 bits, which can be utilized for the decimal or ...
🌐
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!