Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java minus value parsing error

Reply
Thread Tools

Java minus value parsing error

 
 
Saehoon
Guest
Posts: n/a
 
      11-04-2006
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?

 
Reply With Quote
 
 
 
 
Lee Weiner
Guest
Posts: n/a
 
      11-04-2006
In article <(E-Mail Removed) .com>, "Saehoon"
<(E-Mail Removed)> wrote:
>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?


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set div height to 100% minus a fixed pixel value? Ciaran HTML 21 03-24-2010 10:06 PM
SSO authentication via java client minus the web agent rdaly Java 0 06-21-2006 01:47 AM
On Topic: T-minus 32 hours, 7 minutes Briscobar MCSE 122 01-26-2006 05:05 PM
Firefox plus and minus Trond Ruud Firefox 2 12-07-2004 05:31 PM
hyphen vs minus in regex mm Perl 1 09-08-2003 08:27 PM



Advertisments