+ 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
4 ответов
+ 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)
+ 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
0
That's fine, I already gave you 4 possible answers
0
Thanks I have tried it and it worked