You get the warning because the comparison could give you an error. For simplicity, consider that an int or unsigned int were one byte. 0xff would be -1 for the int, but 255 for the unsigned int. Casting won't fix the problem. It'll make the conversion, alright, but if you assign it to an int, that int will be interpretated, later, as an int. The cast converts the value, not the type of variable assigned to. All those could get you into an error situation. When you cast the result of the division, you should cast it to int, to match gravity, not unsigned int.