I am trying to convert String value "0.00008241" into Float as it is
what I can try
String price="0.00008241";
Float f1=Float.parseFloat(price);
Float f2=Float.valueOf(price);
Double f3 =Double.parseDouble(price);
Double f4 =Double.valueOf(price);
but all these return 8.241E-5
then I try it with BigDecimal
BigDecimal tt= BigDecimal.valueOf(Float.parseFloat(price));
it returns 0.00008240999886766076
so any help to convert that price value as it is?
still cant convert it still string?
String price_="0.00008241";
BigDecimal tt= BigDecimal.valueOf(Float.parseFloat(price_));
DecimalFormat df = new DecimalFormat("#.##########");
float price = Float.parseFloat("0.00008241");
String sPrice= df.format(price);
The BigDecimal value can we compare with double value?
Big Decimal is perfect for this conversation:
String price="0.00008241";
BigDecimal decimal=new BigDecimal(price);
System.out.println(decimal); //0.00008241