Conversion help

Convert from string to double?

Page 1 of 1

2 Replies - 1396 Views - Last Post: 05 October 2005 - 09:28 AM Rate Topic: -----

#1 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

Conversion help

Post icon  Posted 05 October 2005 - 09:13 AM

I’m am working on a program that can imports a string from a text box and then converts it to another data type so that I can run it through some formulas.

I think that I need to convert it to a double so that it can have decimals but I cant figure out how to convert a string to a double.

Is a double the best way to go and is there any way to convert from a string to a double?
Is This A Good Question/Topic? 0
  • +

Replies To: Conversion help

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Conversion help

Posted 05 October 2005 - 09:19 AM

String s = "123.456";
double d1 = Double.valueOf(s.trim()).doubleValue();


is one way to do it...there are several, including parseDouble, etc...
Was This Post Helpful? 0
  • +
  • -

#3 Drift-O-Manaic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 83
  • Joined: 19-August 05

Re: Conversion help

Post icon  Posted 05 October 2005 - 09:28 AM

Thank you for your help!!!!!!

It worked perfect!!! :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1