Hi All, I want to get float value of a string, but for small values I get it in the form "6.0E-4". Can any1 help me in getting 0.0006 in Float value???
public class flt1{ public static void main(String kk[]){ String val = "0.0006"; Float resultflt = new Float(val); System.out.println("Flt val is "+resultflt.floatValue()); } } Thanks in advance. Mahesh
Mahesh, try using the code you already wrote. The new Float(String) constructor already understands how to parse "6.0E-04" and the like. Incidentally you can also use Float.parseFloat(String) to get a float directly, without using a Float. Enjoy...
"I'm not back." - Bill Harding, Twister
Mahesh Mamani
Ranch Hand
Joined: Jun 25, 2001
Posts: 110
posted
0
10x Dirk, It worked Mahesh
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.