?
Solved

String to Float (Very important)

Posted on 1998-10-20
3
Medium Priority
?
173 Views
Last Modified: 2010-03-30
How can I convet a String to a float?

0
Comment
Question by:feup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
omok earned 80 total points
ID: 1226033
String floatStr = "1.234";
float floatValue = (new Float(floatStr)).floatValue();
OR
float floatValue = Float.valueOf(floatStr).floatValue();
0
 
LVL 8

Expert Comment

by:diakov
ID: 1226034
Just a remark. Since you say 'important' you also have to put the suggested expression in a try ... catch block to process possible conversion exceptions. Also Float provides some means for testing for the special float numbers like infinity, nan, etc.

Cheers.
0
 

Author Comment

by:feup
ID: 1226035
Thank you very much. You just helped me finishing my project in the university.

Thanx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question