You just need to cast at least one of the operands to a float:

``````float z = (float) x / y;
``````

or

``````float z = x / (float) y;
``````

or (unnecessary)

``````float z = (float) x / (float) y;
``````

### How can I convert integer into float in Java? - Stack Overflow

https://stackoverflow.com/questions/4377842/how-can-i-convert-integer-into-float-in-java

You just need to cast at least one of the operands to a float: float z = (float) x / y;. or float z = x / (float) y;. or (unnecessary) float z = (float) x ...

### Primitive Data Types (The Java™ Tutorials > Learning the Java ...

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

float: The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in ...

### Java Data Types

https://www.w3schools.com/java/java_data_types.asp

int myNum = 5; // Integer (whole number) float myFloatNum = 5.99f; // Floating point number char myLetter = 'D'; // Character boolean myBool = true; ...

### floating point - How to convert float to int with Java - Stack Overflow

https://stackoverflow.com/questions/1295424/how-to-convert-float-to-int-with-java

Yes, the accepted answer says to do the same thing. ... If you want to convert a float value into an integer value, you have several ways to do it that depends on ...

### Java Program to Convert Int to Float

https://www.tutorialkart.com/java/java-int-to-float/

Int is a smaller datatype and float is a larger datatype. So, when you assign an int value to float variable, the conversion of int to float automatically ...

### java中short、int、long、float、double取值范围_人鱼线的博客 ...

https://blog.csdn.net/qfikh/article/details/52832087

2016年10月16日 ... 一、分析基本数据类型的特点，最大值和最小值。1、基本类型：int 二进制位数：32包装类：java.lang.Integer最小值：Integer.