public class Program { public static void main(String[] args) { float a =10.2; float b=5.3; float c=a%b; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

public class Program { public static void main(String[] args) { float a =10.2; float b=5.3; float c=a%b;

Why It is generating lossy conversation error https://code.sololearn.com/cNycLz9L5K8Z/?ref=app

25th May 2020, 1:13 PM
Harsh Vyas
Harsh Vyas - avatar
4 Answers
+ 1
You just need to add f. Like this float a = 0.1f
25th May 2020, 1:50 PM
Jefferson Jadoc
Jefferson Jadoc - avatar
+ 2
double is more precise than float. You have the following options: 1. Calculate with floats, less precise - therefore you have to use float values, e.g.: float a = 10.2f 2. You use double values for each var.
25th May 2020, 1:25 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
You have to add f in the end of the number if you want to assign a double value to float
25th May 2020, 1:26 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 1
Thank you all
25th May 2020, 1:52 PM
Harsh Vyas
Harsh Vyas - avatar