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;
More Related Contents:
- What is the difference between the float and integer data type when the size is the same?
- How do I add an "L" to the end of an integer?
- In java, is there anyway to go from a array of objects that got returned to the number of objects in the array? [closed]
- How do I generate random integers within a specific range in Java?
- How to nicely format floating numbers to string without unnecessary decimal 0’s
- Double vs. BigDecimal?
- Large Numbers in Java
- Why does the behavior of the Integer constant pool change at 127?
- What’s the right way to represent phone numbers?
- How to concatenate int values in java?
- Why does Double.NaN==Double.NaN return false?
- Converting characters to integers in Java
- Why do == comparisons with Integer.valueOf(String) give different results for 127 and 128?
- Java floating point high precision library [closed]
- How != and == operators work on Integers in Java? [duplicate]
- Why does this subtraction not equal zero?
- What do F and D mean at the end of numeric literals?
- What is the inclusive range of float and double in Java?
- Why int j = 012 giving output 10?
- sorting integers in order lowest to highest java
- Multiplication of two ints overflowing to result in a negative number
- Why can’t we use ‘==’ to compare two float or double numbers [duplicate]
- Why do floating-point numbers have signed zeros?
- Java Convert integer to hex integer
- Differences between new Integer(123), Integer.valueOf(123) and just 123
- Java: Inaccuracy using double [duplicate]
- Why does Java think that the product of all numbers from 10 to 99 is 0?
- How can I check if a value is of type Integer?
- How to convert pcm samples in byte array as floating point numbers in the range -1.0 to 1.0 and back?
- int[] and Integer[] arrays – What is the difference?