I have this code:
String progenD_Rep = ‘162.44003131456’
float progenD_Float = Float.parseFloat(progenD_Rep);
but I want the float variable to have 6 decimals. How can I do it?
Regards.
I have this code:
String progenD_Rep = ‘162.44003131456’
float progenD_Float = Float.parseFloat(progenD_Rep);
but I want the float variable to have 6 decimals. How can I do it?
Regards.
Hi Paulo,
this would work (btw., use rather double than float for such long decimal numbers)
import java.text.NumberFormatdouble decimal = 162.44003131456NumberFormat nf = NumberFormat.instancenf.setMaximumFractionDigits(6)decimal = Double.parseDouble(nf.format(decimal))println decimal