dravidnsk
asked on
how to convert from exponential(E) to ordinary float.
Hi ,
I have a problem to convert from exponential(E) to ordinary float.
the exponential value are retrive from database and save as bean that will add in list that go to jsp page .
example : 1234.56E2 to 123456.00
I have a problem to convert from exponential(E) to ordinary float.
the exponential value are retrive from database and save as bean that will add in list that go to jsp page .
example : 1234.56E2 to 123456.00
ASKER
The value i have retrive from the database is 1.25E6 like that it comes i want to set this to some bean ,that bean is added List, that List i used in jsp page for dispaly (Tag lib using)
I dont know where i want to change the value into float (the bean variable datatype is float )
and also i dont know how to change that !!!
I dont know where i want to change the value into float (the bean variable datatype is float )
and also i dont know how to change that !!!
Well then try this code:
public class Test {
public static void main(String args[]) {
String convertedStr = "1234.56E2";
if(convertedStr.indexOf("E") != -1) {
convertedStr = convertedStr.substring(0, convertedStr.indexOf("E") + 1) + "+" + convertedStr.substring(convertedStr.indexOf("E") + 1, convertedStr.length());
}
float fl = Float.parseFloat(convertedStr);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or you can use NumberFormat object to format the numbers to your desired format.
double d = 1.23e+4;
double d = Double.parseDouble("1.23e+