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 ... Q&A ... The float keyword is a data type that can store fractional numbers from 3.4e−038 to 3.4e+038....
🌐
DataCamp
datacamp.com › doc › java › float
float Keyword in Java: Usage & Examples
... value: The value to assign ... { public static void main(String[] args) { float pi = 3.14f; float gravity = 9.8F; System.out.println("Value of pi: " + pi); System.out.println("Value of gravity: " + gravity); } }...
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
[New CS Student]Trouble differentiating between floats and doubles--why is 23.5 considered a double?
Every decimal number literal will be considered a double by default unless specified as float with the f. Same goes for whole numbers being integers by default. More on reddit.com
🌐 r/learnjava
7
5
August 7, 2021
Float and Double calculations going wrong.
https://stackoverflow.com/a/27598164/1879409 https://en.m.wikipedia.org/wiki/IEEE_754 More on reddit.com
🌐 r/javahelp
11
1
May 6, 2021
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Float.html
Float (Java Platform SE 8 )
April 21, 2026 - If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns.
🌐
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?
If all of the values fall within the range of a float, it makes sense to use the smaller Java data type in this situation, otherwise the array elements needlessly consume memory. Data precision can be a problem with double and float types because binary numbers don’t always convert cleanly to decimals. For example, the following program prints out 11.3999 as the sum of 5.6 + 5.8:
🌐
Study.com
study.com › business courses › java programming tutorial & training
Java: Floating Point Numbers - Lesson | Study.com
October 3, 2018 - A float data type in Java stores a decimal value with 6-7 total digits of precision. So, for example, 12.12345 can be saved as a float, but 12.123456789 can't be saved as a float.
🌐
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 ...
Find elsewhere
🌐
Sololearn
sololearn.com › en › Discuss › 1548 › what-is-a-float-please-explain-with-example
What is a float ? please explain with example
Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
Oracle
docs.oracle.com › en › java › javase › 22 › docs › api › java.base › java › lang › Float.html
Float (Java SE 22 & JDK 22)
July 16, 2024 - 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 ...
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › lang › Float.html
Float (Java SE 11 & JDK 11 )
January 20, 2026 - If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns.
🌐
ZetCode
zetcode.com › java › lang-float
Java Float Class - Complete Tutorial with Examples
This example demonstrates the differences between Float and Double. Float has less precision (about 6-7 decimal digits) and smaller range than Double but uses half the memory. Choose Float when memory is critical and precision requirements are modest. ... In this article, we've covered all major aspects of the Java ...
🌐
Jtcindia
jtcindia.org › tutorials › java › java_lang_float.php
Java Float Class - Methods and Usage
2. The java.lang.Float class is a final class, so no other class can extend it, and we cannot override any method of the java.lang.Float class · public class JTC { public static void main(String[] args) { Float f1 = newFloat(10.67 f); Float f2 = newFloat(23.45 f); Float f3 = f1 + f2; ...
🌐
Scaler
scaler.com › home › topics › java float
Java Float - Scaler Topics
May 4, 2023 - In this example, we are going to see a java program that creates a float variable and a string variable and then uses the valueOf() method of the java Float class to convert them into a Float value and then prints the results.
🌐
GeeksforGeeks
geeksforgeeks.org › java › float-parsefloat-method-in-java-with-examples
Float parseFloat() method in Java with examples - GeeksforGeeks
July 11, 2025 - // Java Code to implement // parseFloat() method of Float class class GFG { // Driver method public static void main(String[] args) { try { String str = ""; // returns the float value // represented by the string argument float val = Float.parse...
🌐
YouTube
youtube.com › watch
Floating point data types in Java - YouTube
Hello everyone! Welcome back to Dev Portal, where we simplify programming concepts for you. Today, we're diving into the world of floating point variables in...
Published   July 9, 2024
🌐
Iut-fbleau
iut-fbleau.fr › docs › java › api › java.base › java › lang › Float.html
Float (Java SE 21 & JDK 21)
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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-number-floatvalue-method
Java Number.floatValue() Method - GeeksforGeeks
May 15, 2025 - Example 1: In this example, we are going to convert Integer and Double to float. ... // Java program to demonstrate // floatValue() with Integer and Double import java.lang.Number; public class Geeks { public static void main(String[] args) ...