Results 1 to 5 of 5

Thread: [resolved]loss of persition error, how to tell the compiler I don't care

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    74

    [resolved]loss of persition error, how to tell the compiler I don't care

    Exactly what the subject says
    Last edited by vagabon; Nov 2nd, 2005 at 08:17 AM. Reason: answered

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: loss of persition error, how to tell the compiler I don't care

    What's the line of code causing the error?


    Is there anything after the error such as: expected double, but found int?

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: loss of persition error, how to tell the compiler I don't care

    I suppose you mean "precision"? ("Persition" is not a word.)

    I further suppose the error says "loss of precision"?

    I further suppose you have code like this:
    Code:
    double d = 213.392;
    // ...
    int i = d;
    Or perhaps to float. Whatever. The solution is to explicitely cast the values:
    Code:
    double d = 213.392;
    
    int i = (int)d;
    float f = (float)d;
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    74

    Re: loss of persition error, how to tell the compiler I don't care

    I'll check and see if that works when I get back on the other PC at school that has the file on it. I was doing calculations and if I stored an vareable as a double it would cause an infinate loop so I switched it to an int or a float (i think an int) and it told me that.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: loss of persition error, how to tell the compiler I don't care

    You compared doubles with ==. You shouldn't do that. Use < and >.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width