Wednesday, September 29, 2010

why division is not a shift

For signed values division by a power of two is not equal to shift. This can be easily showed mathematically: suppose x is negative then x>>1 is ceil((x+1)/2)) - 1 = ceil(x/2 + 1/2) - 1 = floor(x/2) which is not the x/2 = ceil(x/2).

No comments:

Post a Comment