JDK-1231955 : No direct way to convert from String to float or double
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.4
  • CPU: sparc
  • Submitted: 1995-12-14
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Relates :  
Description
For conversion to int there is Integer.parseInt, but there appears to
be no directly corresponding function for floats and doubles.
Instead you have to convert first to Float or Double, then to
float or double, if you get my meaning.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

WORK AROUND See Description.
11-06-2004

SUGGESTED FIX Add functions similar in intent to Integer.parseInt.
11-06-2004

PUBLIC COMMENTS No direct way to convert from String to float or double
10-06-2004

EVALUATION Sounds reasonable. The native method Double.valueOf0() indeed returns a double, but we seem to want to box it. Since we are not allowed to overload on return type, we will have to have a parseDouble. But richard.tuck@Eng is talking about removing the native method, so I am not sure the wrapper is such an overhead. anand.palaniswamy@Eng 1997-11-07 This seems like a very reasonable API addition to be consistent with the other classes which already have a parse<type> method. I'm not really sure if the performance argument will hold since we are going to reimplement the code which does double parsing in Java, so it will probably become slower. At least though we'll have the API and we can worry about the performance of it later. tom.rodriguez@Eng 1998-03-31 Float and Double now have the parseFloat and parseDouble methods that allow direct conversion to float or double. michael.mccloskey@eng 1998-04-24
31-03-1998