#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Sacramento
    Posts
    3
    Rep Power
    0

    How to convert double to Int


    double cd1110 = Double.parseDouble(request.getParameter("cd1110"));

    I want to convert the double for comparing:

    like:

    if( (cd1110.toInt())=0){

    do something.....
    }

    Is this is correct ?

    Any help greatly appreciated.
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    The javadoc [http://java.sun.com/j2se/1.4/docs/api/] is your friend!

    Double.intValue() converts a Double to an int. I don't think there's any way to go directly from a double to an int.
    -james
  4. #3
  5. dont click here
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    409
    Rep Power
    13
    You can go directly through type casting
    Code:
    int i = (int)cd11110
    if(i==0){
      //DO SOMETHING
    }

IMN logo majestic logo threadwatch logo seochat tools logo