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
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Float.html
Float (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... The Float class wraps a value of primitive type float in an object.
🌐
W3Schools
w3schools.com › java › ref_keyword_float.asp
Java float Keyword
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
The float keyword in Java is a primitive data type that represents a single-precision 32-bit IEEE 754 floating point.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Float.html
Float (Java SE 17 & JDK 17)
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.
🌐
Study.com
study.com › business courses › java programming tutorial & training
Java: Floating Point Numbers - Lesson | Study.com
October 3, 2018 - Floating point numbers are also called floating point literals in Java. For calculations using decimal values, Java supports two basic data types: float and double. Together, these support decimal or floating point numbers in the Java programming ...
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › lang › Float.html
Float (Java SE 21 & JDK 21)
January 20, 2026 - In addition, this class provides several methods for converting a float to a String and a String to a float, as well as other constants and methods useful when dealing 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 has a discussion of equality, equivalence, and comparison of floating-point values that is equally applicable to float values.
🌐
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.
Published: May 23, 2026
Find elsewhere
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java float tutorial with programming examples
Java Float Tutorial With Programming Examples
April 1, 2025 - Float is a single-precision value that has a width of 32 bits in storage. On some processors, this single precision is faster and takes less size when compared to the double-precision.
🌐
iO Flood
ioflood.com › blog › java-float
Java Float Keyword Explained: Usage and Examples
February 26, 2024 - In this example, we declare a float variable named ‘num’ and initialize it with the value 1.11. The ‘f’ at the end of the number is necessary because Java interprets decimal numbers as double by default.
🌐
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 ...
🌐
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 - 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.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › java_lang_float.htm
Java - Float class with Examples
The Java 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. Following is the declaration for java.lang.Float class − Following are the fields for java.lang.Float ...
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Float.html
Float (Java Platform SE 7 )
Java™ Platform Standard Ed. 7 ... The Float class wraps a value of primitive type float in an object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-float-class-in-java
Java.Lang.Float class in Java - GeeksforGeeks
April 5, 2023 - DSA in Java · Java Collection · Last Updated : 5 Apr, 2023 · Float class is a wrapper class for the primitive type float which contains several methods to effectively deal with a float value like converting it to a string representation, ...
🌐
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 - The float keyword in Java is a primitive data type, and its size limit is 4 byte or 32 bits (1 byte = 8 bits) single-precision IEEE 754 (Standard for Floating-Point Arithmetic) floating-point number, that is it can allow up to 6 digits precision after the decimal.
🌐
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 - P where Sign, FloatingPointLiteral, HexNumeral, HexDigits, SignedInteger and FloatTypeSuffix are as defined in the lexical structure sections of The Java™ Language Specification, except that underscores are not accepted between digits. If s does not have the form of a FloatValue, then a NumberFormatException is thrown.
🌐
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 - 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.
🌐
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.
🌐
CodeGym
codegym.cc › java blog › java numbers › java float keyword
Java Float Keyword
June 30, 2022 - All real fractional numbers in Java are Double by default, and the syntax of the language also emphasizes this. If you really want to work with the float type, you need to specify it explicitly with an f terminating the number.