Hi guys.
The following line:
boxCoor[0] = floor(v_pos[0]/(double(pars::XSIZE)));
gives me a warning:
warning: converting to ‘int’ from ‘double’
boxCoor is devined as a vector<int>
XSIZE is static const int
and v_pos is it's own class which is defined via:
class vec{
vec::vec(){ //those are declared in the header actually.
double coor[] = {0,0,0};
int length = 3;
}
double vec::operator[] (int index){
if(index >0 && index < length){
return coor[index];
}else{
cout <<"Error"
exit(1);
}
}
How can I stop this warning from appearing?
Thanks
With an explicit cast:
boxCoor[0] = int ( floor(v_pos[0]/(double(pars::XSIZE))) );
Or remove the -Wconversion compiler option