After running the following lines :
double d=Float.parseFloat("9.99");
System.out.println(""+d);
I got this : 9.989999771118164
I expected to see : 9.99
Why and how to fix this ?
=======================================================
Edit : What I should have used was : double d=Double.parseDouble(“9.99”) which prints out 9.99. That’s my fault, but it’s interesting to see the detailed answers, thanks !
If you try
Double.parseDouble()instead you will the expected result.