error of integer overflow
- by user308565
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