Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Java minus value parsing error

Thread view: 
Saehoon - 04 Nov 2006 01:57 GMT
Hi guys,
I'd like to parse the String to double value.
But String has a minus value such as "-1", "-2"...
I used the Double.parseDouble(String s); method.

The example code is

String s = "-1";
double d = Double.parseDouble(s);

This doesn't seem to work properly.
How can I correctly parse the minus value?
Lee Weiner - 04 Nov 2006 02:30 GMT
>Hi guys,
>I'd like to parse the String to double value.
[quoted text clipped - 8 lines]
>This doesn't seem to work properly.
>How can I correctly parse the minus value?

What do you mean, it doesn't seem to work properly?
It works perfectly for me.

public class ParseDouble
{
 public static void main( String[] args )
 {
   String s = "-1";
   double d = Double.parseDouble( s );
   System.out.println( d );
 }
}

Displays -1.0

Lee Weiner
lee AT leeweiner DOT org


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.