Thread: DevCPP assignment question

  1. #1
    Registered User
    Join Date
    May 2002

    DevCPP assignment question

    Im having problems with compiler warnings. This is what i came up with to fix it.

    double d_x, d_y;
    int i_z, i_a;
    d_x = d_y * (double) i_z;
    i_a = (int) d_x;
    Now this is fine ('cuase it works), but i wish i could use this next method and not get any warnings. Any ideas?

    double d_x;
    int i_z, i_a;
    i_z = i_a * d_x;
    Oh the compiler warning is "assignment to int from double". Thanks.
    I never lie... except for right now.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    I think the point is there is a typecast involved.
    Shouldnt be too difficult to accomodate with a few extra characters, as in your first example.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2004
    As per your second method, Why would you want to multiply a double by an int and save it to an int ? WOuldn't it be wiser to save it to a double ?
    Life is a piece of chocolates

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003

    Re: DevCPP assignment question

    double d_x;
    int i_z, i_a;
    i_z = int(i_a * d_x);
    Typecast it

    your code here....


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. assignment operator question
    By l2u in forum C++ Programming
    Replies: 5
    Last Post: 12-17-2007, 09:48 AM
  2. array assignment question
    By threahdead in forum C Programming
    Replies: 2
    Last Post: 08-17-2003, 05:36 PM
  3. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Replies: 2
    Last Post: 12-17-2001, 06:40 PM