+ 2

lossy conversion from double to float

I wrote a simple Java program I am getting this error " lossy conversion from double to float" https://code.sololearn.com/cC58ynAZy405/?ref=app

30th Jul 2019, 10:56 AM
Coding
Coding - avatar
4 Answers
+ 2
You cannot convert a datatype to another datatype when there is a chance of information loss, unless you use type casting. In 0.05 * p + p, 0.05 is a double. You have to make it a float: 0.05f * p + p or (float)0.05 * p + p (Also 0.05 * p + p id the same as 1.05 * p)
30th Jul 2019, 11:14 AM
Airree
Airree - avatar
+ 1
I used double data type it worked but I can't do conversion in 4 decimal point because the answer is exponential 4E-6 https://code.sololearn.com/cCOaMbiDR7Qy/?ref=app
30th Jul 2019, 11:17 AM
Coding
Coding - avatar
0
That's fine, I already gave you 4 possible answers
30th Jul 2019, 11:19 AM
Airree
Airree - avatar
0
Thanks I have tried it and it worked
30th Jul 2019, 11:22 AM
Coding
Coding - avatar