Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert string into float value in android [duplicate]

Tags:

Possible Duplicate:
String from EditText to float

In application I want to convert the entered string in edit box to the corresponding value like 233243664376347845.89 to corresponding float value. But it returns like IE10 after some number for example 23324366IE10 Please help me. My code is -

NumberFormat format = NumberFormat.getInstance(Locale.US);  try  {     number = format.parse(e1.getText().toString()); } catch (ParseException e)  {     // TODO Auto-generated catch block     e.printStackTrace(); } 

The edit text length is greater then 20 digits,also i want to minus two edit text float values...

like image 836
user1235251 Avatar asked May 24 '12 10:05

user1235251


People also ask

How to convert String value to float?

Converting the string to float. Float floatVal = Float. valueOf(str). floatValue();

How to cast String to float?

We can convert a string to float in Python using float() function. It's a built-in function to convert an object to floating point number. Internally float() function calls specified object __float__() function.

How to extract float from String in Java?

Float c=Float. parseFloat(a); Float d= Float. parseFloat(b);


1 Answers

String s = e1.getText().toString(); Float f= Float.parseFloat(s); 
like image 149
Parag Chauhan Avatar answered Nov 03 '22 21:11

Parag Chauhan