error of integer overflow

Posted by user308565 on Stack Overflow See other posts from Stack Overflow or by user308565
Published on 2010-05-07T18:01:23Z Indexed on 2010/05/07 18:08 UTC
Read the original article Hit count: 575

Filed under:
|

This the part of my OpenGL code, I am getting an error for :

struct Ball {
    float x;
    float y;
    float rot;
    float dir;
    bool rmv;
    Ball* next;
};

Ball* curBall;
void addBall() {
    if (balls==NULL) {
        balls=new Ball;
        balls->next=NULL;
        curBall=balls;
    } else {
        curBall->next=new Ball;
        curBall=curBall->next;
        curBall->next=NULL;
    }
    curBall->x=((float)rand()/(float)(RAND_MAX+1))*(ww-1) +1;
    curBall->y=((float)rand()/(float)(RAND_MAX+1))*(wh-1) +1;
    curBall->dir=((float)rand()/(float)(RAND_MAX+1))*(2*PI-1) +1;
    curBall->rot=((float)rand()/(float)(RAND_MAX+1))*(359) +1;
    curBall->rmv=false;
}

error :
In function ‘void addBall()’:
file.cpp:120: warning: integer overflow in expression
file.cpp:121: warning: integer overflow in expression
file.cpp:122: warning: integer overflow in expression
file.cpp:123: warning: integer overflow in expression

© Stack Overflow or respective owner

Related posts about c++

Related posts about integer-overflow