"Ondra Holub" <on*********@post.czwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
>
BTW: x >8 is IMO not more readable than x / 256 and I bet every
compiler is able to change x / 256 to bit shift automatically (of
course when x is integer value).
Of course when x is an _unsigned_ integer. -1 / 256 == 0, but on most
implementations, -1 >8 == -1 due to the use of the arithmetic shift right
on a signed int (and an implementation using a logical shift left can't even
use that instruction for dividing signed integers ;)). This leads to the
need for extra (perhaps relatively expensive, of course depending on the
platform) checks, therefore a regular divide instruction rather than a shift
can be chosen to "optimize" the expression.
- Sylvester