Computer Science Canada

Converting a string to a double

Author:  Token [ Thu May 04, 2006 9:53 am ]
Post subject:  Converting a string to a double

I am trying to make a calculator program with GUI and stuff and i have all my keys working but all i need is to do the calculations part. when you press a number or the decimal key it adds the number or decimal to the end of a String, like a calculator does. but in order to do the calculation I'll need to convert this String to a Double, and i cant do that with
code:
Double.parseDouble(string)

because i'm using RTP. please help

thanks

-Jordan

Author:  HellblazerX [ Thu May 04, 2006 10:05 am ]
Post subject: 

I used the same command in RTP, and it worked perfectly fine for me. Perhaps you forgot to assign that value to something, like this:

code:
double = Double.parseDouble (string);


What version of RTP are you using?

Author:  Token [ Thu May 04, 2006 7:32 pm ]
Post subject: 

Version 1.0.6

Yah, Assigned it to a variable, but it didnt work, i couldent find it in the double class in my help file so i'm guessing its not with my version.

so no one can think of any other commands?

Author:  wtd [ Thu May 04, 2006 7:48 pm ]
Post subject: 

Don't use RTP. Download the JDK from Sun and there won't be any question about your environment being borked.

Author:  codemage [ Fri May 05, 2006 8:54 am ]
Post subject: 

If it's being graded in school, it'll be by a teacher with the same crummy version of RTP.

It's bizarre that your version is so old though. Current ver is 1.7 - and it's not exactly new.

Author:  Token [ Sat May 06, 2006 11:08 pm ]
Post subject: 

code:
Double.valueOf (double d).doubleValue ()


tada! all thanks to http://javaboutique.internet.com I looked at a copy of a calculator program they made and found that little tidbit of greatness. Thanks for your help, and heres my (semi finnished) applet.


: