Hi,

double doubleValue = (new Double(doubleString)).doubleValue();

Will convert a Double object to the equivalent double value.  See example
code that follows if confused.

You may like to concider using a float, if values are going to similar to
0.5. It will half your memory requirements!

Hope that helps,

Dan.



import java.lang.*;

public class DoubleStringTest{

  public static void main(String[] args){

      String doubleString = "0.5";

      double doubleValue = (new Double(doubleString)).doubleValue();

      System.out.println(doubleValue);

  }

}
    -----Original Message-----
    From: Kirstin Battershill <[EMAIL PROTECTED]>
    To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
    Date: 18 May 1999 17:41
    Subject: Re: another basic question


    But this is my problem,   but I don't want a DOUBLE OBJECT,
    I want a DOUBLE VALUE / TYPE.  I have tried the below method but then I
have the problem of converting the Double d object to the value which the
database will take without throwing an exception because it wants a double
whilst  I am giving it a  Double  And it is this that is causing me the
grieve.

    I tried the Double.parseDouble,  but I just get  :  not found in
java.lang.Double

    Kirstin





    David Mossakowski wrote:

        Double d = Double.valueOf(stringRepresentationOfDouble);
        or
        Double d = new Double(stringRepresentationOfDouble);
        (remeber to catch NumberFormatException)

        dvae.

        P.S. Please refer to documentation (trying to be polite but RTFM :).

        Kirstin Battershill wrote:

        > Hi Guys,
        >
        > another basic question
        >
        > I am taking a set double value from doGet (0.5 to be precise)
        >
        > and want to pass it into a double variable in doPost and then pass
the
        > double value into a database field which is double as well.
        >
        > My problem is,  this is the first time I have used a double and I
have
        > no idea about the request.getParameter bit.
        >
        > with integers you  obviously use Integer.parseInt(STRING), but I
have
        > tried similar combinations using doubleValue and valueOf and also
        > tried declaring a new Double object and parsing that.
        >
        > But to no avail.
        >
        > Help
        >
        > Thanks
        >
        > Kirstin
        >
        >

        --
        David Mossakowski        [EMAIL PROTECTED]
        http://www.dwdog.com/styk      212.310.7275

        "I don't sit idly by, I'm planning a big surprise"
        F         U         G         A        Z        I


___________________________________________________________________________
        To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
        of the message "signoff SERVLET-INTEREST".

        Archives:
http://archives.java.sun.com/archives/servlet-interest.html
        Resources:
http://java.sun.com/products/servlet/external-resources.html
        LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to