I just wonder how can i round to the nearest zero bitwise? Previously, I perform the long division using a loop. However, since the number always divided by a number power by 2. I decide to use bit shifting. So, I can get result like this:
12/4=3 13/4=3 14/4=3 15/4=3 16/4=4 can I do this by performing the long division like usual?
12>>2 13>>2 if I use this kind of bit shifting, are the behavior different for different compiler? how about rounding up? I am using visual c++ 2010 compiler and gcc. thx
int x; int y; y = x/4;then any compiler worth a damn should convert that/4into a bitshift for you (with optimisations turned on).floating-pointinvolved?