This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to covert a number in string form to float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to covert a number in string form to float " Watch "How to covert a number in string form to float " New topic
Author

How to covert a number in string form to float

Amir Abbas
Greenhorn

Joined: Mar 20, 2002
Posts: 3
hi
plz help me How to covert a number in string form to float form Thanx in advance
Amir
hi_amir@hotmail.com (for msn)


I want to be a professional progmammer help me add me on msn at hi_amir@hotmail.com
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Hello,
Welcome to JavaRanch.
The short answer is:
String string = "123";
int number = Integer.parseInt(string);
or
String string = "123.45";
double number = Double.parseDouble(string);
If you'd like more information on the subject, I recommend doing a search on the beginner's forum. The link to the search page is at the top-right of this page.
Good Luck.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Amir Abbas
Greenhorn

Joined: Mar 20, 2002
Posts: 3
I had tried the float one method which you tell but it give error
i have jdk1.3
plz help
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Did you use
String string = "123";
int number = Integer.parseInt(string);
String string = "123.45";
double number = Double.parseDouble(string);
in the same scope?
Just use different variables and it should work fine.
-anthony
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Amir,
If you are still having difficulties, it may be useful if you were to post the code you are trying to compile as well as the error messages you are receiving.
Note: When posting code, please enclose it with the [ code ] and [ /code ] tags (click on the "CODE" button below the message posting textbox).
Good Luck.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Ah, thanks for the tip!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to covert a number in string form to float
 
Similar Threads
MD5
Generics question.
String to Float
Converting a Document type into String
Ascii to hex converter